Skip to content

Commit

Permalink
Fix body setting in list example
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed Apr 24, 2014
1 parent bfddf97 commit e3314c4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/mailing_list.phps
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ $mail->addReplyTo('[email protected]', 'List manager');

$mail->Subject = "PHPMailer Simple database mailing list test";

//connect to the database and select the recipients from your mailing list that have not yet been sent to
//Same body for all messages, so set this before the sending loop
//If you generate a different body for each recipient (e.g. you're using a templating system),
//set it inside the loop
$mail->msgHTML($body);
//msgHTML also sets AltBody, so if you want a custom one, set it afterwards
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';

//Connect to the database and select the recipients from your mailing list that have not yet been sent to
//You'll need to alter this to match your database
$mysql = mysql_connect('localhost', 'username', 'password');
mysql_select_db('mydb', $mysql);
$result = mysql_query("SELECT full_name, email, photo FROM mailinglist WHERE sent = false", $mysql);

while ($row = mysql_fetch_array($result)) {
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->msgHTML($body);
$mail->addAddress($row['email'], $row['full_name']);
$mail->addStringAttachment($row['photo'], 'YourPhoto.jpg'); //Assumes the image data is stored in the DB

Expand Down

0 comments on commit e3314c4

Please sign in to comment.