Re: Mass Mailing Using PHP

From: Date: Mon, 27 Sep 2004 16:57:50 +0000
Subject: Re: Mass Mailing Using PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-197980@lists.php.net to get a copy of this message
I make a app that send mass mailing with php. This app work with smarty for make a template HTML - plain text and customizer the content in the email body(name, last nane, links, etc).I'm construction a stadist system for: status mailing, message readed, links opened, mail bounce, etc.I'm using a class the pear. Regards, JP > Are your users' details in a database? >> >> If so simply read through the database mailing to each user, something > like: >> >> <?php >> $message = "Hello everyone"; >> $subject = "Hello"; >> $headers = "From: Someone <someone@somewhere.com>\r\n"; >> $sql = "SELECT user_name, email FROM user"; >> $result = mysql_query($sql) or die ("Query failed: " . mysql_error()); >> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) >> { >> $email = $row['email']; >> mail($email, $subject, $message, $headers); >> } >> ?> >> > If the message is the same for each user then use the Bcc header and > save yourself some overhead. There is no need to send a new mail to > each recipient in a loop. If your on a shared system I'm sure your ISP > will appreciate not getting bombed by your script. ;-) > > loose example: > > while ($row = mysql_fetch_assoc($result)) > { > $bccList .= "<{$row['email']}>,"; > } > /*remove the last comma*/ > $bccList = substr($bccList,0,-1); > > $headers .= "Bcc: $bccList\n"; > > /*mail only one time*/ > mail($email, $subject, $message, $headers); > > Jim Grill > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#197980) next »