PHPMailer - problems



Hi

I've got a script for mailing my newsletter list (several thousand
addresses). I used to use the mail() command in PHP but switched to
using PHPMailer a few months ago.

The problem is that batches of emails will fail to send. This seems to
be fairly random, but it's almost like the system "clogs up" and 40 or
50 emails return an error, then it clears itself and does another few
hundred OK, then a batch of errors etc etc. The PHPMailer error is
usually "from_failed".

I'm wondering if there is some timing problem, or maybe my ISP has some
throttle mechanism that blocks for a while once you've sent too many in
quick succession.

If I run the script again, selecting just the addresses that failed,
then a proportion of them will work OK this time, but not all. I end up
having to run the script several times, each time with less addresses,
to try and get as many successful sends as I can.

The gist of the script is here:

require("class.phpmailer.php");

// Set to use SMTP via my ISP
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtpauth.xxx.xxx.com";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "xxxxx"; // SMTP username
$mail->Password = "xxxxx"; // SMTP password

// Set from name etc
$mail->From = "newsletters@xxxxxxxxxxxx";
$mail->FromName = "My Newsletters";
$mail->AddReplyTo("newsletters@xxxxxxxxxxxx", "My Organisation");
$mail->WordWrap = 100; // set word wrap to 100 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Mailer = "smtp";

//connect to server
require('login.php');

$sql = "SELECT * from mailshots where lastsent < '${mailbefore}' ORDER
BY email";

// execute SQL query and get result
$result = mysql_query($sql,$dbH) or die("Error accessing database(1),
please try later.");
$count = 0;
$today = date("F j, Y"); // March 10, 2001, 5:16 pm

// for all recipients...
while ($r = mysql_fetch_array($result))
{
$count++;
echo $count . "<br>";
$pemail = $r["email"];
echo $count . "..About to email to " . $pemail;

$mail->AddAddress($pemail);

$mail->Body = $htmlbody;
$mail->AltBody = $textbody;

$stat = $mail->Send();

if(!$stat)
{
echo "....<b>Message could not be sent?</b><br>";
echo "Mailer Error: " . $mail->ErrorInfo . "<br>";
}
else
{
echo "....Mail sent<br>";
}

$mail->ClearAddresses();
$mail->ClearAllRecipients();

}

.



Relevant Pages

  • Re: PHPMailer - False Positives
    ... My problem is that the PHPMailer action is returning a "true" result ... I use two email list groups - one has 18 listed recipients (and sends ... Initially the script created a new object for each email (sending them ... each execution), but the fault was evident in each configuration. ...
    (comp.lang.php)
  • Re: php Mailer problem
    ... > It uses PHP Mailer BUT I can't see in the script where it tells PHP ... look for a call to the PHPmailer constructor. ...
    (alt.php)
  • Re: PHPMailer - False Positives
    ... Michael Fesser wrote: ... script - PHPMailer. ... I mean - the PHP mail() function is *amazingly* simple to use ...
    (comp.lang.php)
  • inbox and PHPmailer
    ... i am using PHPmailer in my PHP project i try to send the messages in my ... script when some event happen by the user. ... messages to go to the INBOX in the client email ????? ...
    (comp.lang.php)
  • Body/Subject/Headers Mix-up
    ... I'm an experienced PHP user, but am having a nightmare with one aspect ... of PHPMailer. ... Can't find anyone else posting with the same problem on ... The script sends ok, but what I get at the other end is this (I've ...
    (comp.lang.php)