New problem.
I've decided to use PHPMailer in my Newsletter sending script. I've done something like this successfully before with just mail(), but this time, the emails never arrive. For the record, mail() works fine on the same server I'm using PHPMailer on.
This is my code snippet:
Code: Select all
//Include the PHP Mailer and SMTP class
include('includes/php/phpmailer/class.phpmailer.php');
include('includes/php/phpmailer/class.smtp.php');
//Initiate the PHPMailer
$mailer = new PHPMailer();
//Set some PHPMailer properties
$mailer->Subject = EMAIL_SUBJECT; //Subject
$mailer->FromName = EMAIL_FROM_NAME; //From name
$mailer->From = EMAIL_FROM; //From email
$mailer->isHTML(true); //HTML email activation
$mailer->isMail(); //Use PHP's mail() function
$mailer->AltBody = "blah."; //Text body
//Initiate a counter
$counter = 0;
//Loop through all the people on the mailing list
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
//Add them to the list of BCC recipients
$mailer->AddBCC($row['email'], $row['name']);
$counter++;
}
//Set a formatted date string
$tmp = explode('-', $today);
$dateformatted = $tmp[2] . '/' . $tmp[1] . '/' . substr($tmp[0], 2);
//Set the HTML email body
$mail->Body = str_replace('{DATE}', $dateformatted, file_get_contents(EMAIL_HEADER)) . //Add the HTML header
$htmlbody . //Add the HTML body
file_get_contents(EMAIL_FOOTER); //Add the HTML footer
//Send the email
if($mailer->Send()) {
//Set a success message
$msg .= '<font color="green">You have sent <b>' . $caramount . '</b> set(s) of car details to <b>' . $counter . '</b> person(s).</font>';
} else {
//Set an error mesage
$msg .= '<font color="red">The newsletter sending failed.<br />Please try again.</font>';
}I have error reporting set to E_ALL, and get nothing.
When sent, the $msg echo'd is always the success one, with the right amount in each of my counters.
Does anyone have any experience with PHPMailer and can point me in the right direction? I've Google'd for some good usage examples but can't find any half decent ones except the one on PHP Freaks.
Thanks.