Forum Moderators: coopster
I have written a script to open a mailing list and loop through extracting the email addresses. With each address it invokes an instance of php mailer and sends via smtp.
We limimt the list to only 50 names as I don't want to upset my host.
It appears though with as little as 50 names we may get as many as 80% send failures. While many of these are valid addresses.
What should I do,
Use smaller lists, build in a delay between each send so as not to overload the server.
<code>
<?
// load required class files
require("class.phpmailer.php");
// load required include files
include("commonhtml.php");
//establish common page defaults
$body_html = "";
$body_text = "";
$subject = "Newsletter No. 6";
$fromAddress = "someaddress@mydomainname.com";
$fromName = "My site";
$replyToAddress = "name@domain.au";
$file_html = "newsletter6.htm";
$file_text = "newsletter6.txt";
$lines = file($file_html);
if( count($lines) > 0 ){
while(list($k,$v)=each($lines)){
$body_html .= $v;
}
}
else{
die("Unable to Open $file_html.");
}
$body_text = "If you are reading this, your Email client was unable to display \n";
$body_text .= "our cool HTML newsletter. We have prepared an online version for you \n";
$body_text .= "it is available at \n";
$body_text .= "http://www.mydomain.au/index.htm?page=html/newsletter6.htm\n";
if(!($dataFile = fopen("maillist.txt","r+"))){
print("file could not be opened");
exit;
}
while(!feof($dataFile)){
// read a line from the file
$line = fgetss($dataFile, 255);
trim($line);
if(!($line=="")){
$arrayRecipients[] = $line;
}
}
HTML_Top("Send Mail");
?>
<p align="left">
<?
$arrFailures = array();
while(list($k, $v)=each($arrayRecipients)){
$mail = new phpmailer();
$mail->PluginDir = "./";
$mail->IsSMTP(); // send via SMTP
$mail->Host = "mail.mydomainname.com"; // SMTP servers
$mail->SMTPAuth = false; // turn on SMTP authentication
$mail->From = $fromAddress;
$mail->FromName = $fromName;
$mail->AddAddress($v);
$mail->AddReplyTo($replyToAddress);
$mail->WordWrap = 65; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = $subject;
$mail->Body = $body_html;
$mail->AltBody = $body_text;
if(!$mail->Send())
{
echo "$v - <font color=\"red\">send failure</font><br>";
}
else{
echo "$v - send successful<br>";
}
}
?>
</p>
<p align="left">
<a href="filename removed">Return to the Mailing List Manager</a>.
</p>
<?
HTML_Bottom();
?>
</code>
[edited by: jatar_k at 2:52 am (utc) on Feb. 25, 2003]
[edit reason] removed specifics [/edit]