PHPMailer - problems
- From: softap@xxxxxxxxx
- Date: 11 Oct 2005 03:01:54 -0700
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();
}
.
- Prev by Date: Re: HTML quickform: opening a new form when process() is execuited
- Next by Date: char to integer conversion ???
- Previous by thread: Pear mail Setup
- Next by thread: char to integer conversion ???
- Index(es):
Relevant Pages
|