Automated Emailing

We have a list of email addresses we want to send a fixed format email to.

The php program is in the attached file called email_batch.txt.

A sample of a small file of email addresses is attached in the file email_text.txt.

The script was run & the email was received by some (but not all) of the reciepients.

We are not clear that the script is working right.

Are there any problems with this script that would cause it to fail?
email-batch.txt
email-test.txt
Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
>>A sample of a small file of email addresses is attached in the file email_text.txt
you don't have comma-separated list of email addresses. you have one email address per line. So try this :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
<head>
	<title>Test Emailing</title>
</head> 
<body>
<?php
$thefile = "data/email_batch.csv";
		$subj = "A Novel Holiday Gift Idea";
		$body = "<center>WHAT A NOVEL HOLIDAY GIFT!!</center><br><br>";
		$body = $body . "<b>Send a loved one a Personalized Holiday CD in which the receipient's name is sung 8 times</b> with loving wishes for the Holiday Season. It is sung to the same timeless tune as the ZOOM Birthday Song but with lyrics for the Holidays.It comes witha beautiful gift box for easy storage and with a special treat of a framed 4x6 photo of Captain Zoom and all his friends.Every name and spelling is available at no additional charge. This one of a kind gift will be loved by all and will be played over and over.<br><br>";	
		$body = $body . "You receive the Personalized Holiday Cd, the gift box, the 4x6 framed photo of Captain Zoom and his friends for $22.95 plus $6.95 for postage and handling and we will upgrade the shipping to priority mail to insure prompt trackable delivery. If you buy two or more cd's, ther will be no additional postage.\r\n<br><br>";		
		$body = $body . "As our Holiday gift to you, when you purchase 3 or more Personalized cd's whether for the Holiday Season or for a Birthday, THE 4TH ONE IS FREE!!! Please visit our website at  <a href='http://www.captainzoom.com'>www.captainzoom.com</a> in order to hear an excerpt of the songs and to place your order. For names not on the website or for other information, please call toll free 1-800 543 9112.<br>";		
		$header  = "MIME-Version: 1.0\r\n";
		$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
		$header .= "From: noreply@captainzoom.com\r\n";	 
	$open = fopen($thefile, "r");
	if($open) {
		$data = file($thefile);
		foreach($data as $mailto){
			$mres = mail($mailto, $subj, $body, $header);	
?>
mail sent to = <? print $mailto; ?><br>
<?
		}
		fclose($open);
	}
	?>
		
</body>
</html> 

Other than that, it's possible the spam filters of the receipient's accounts are trashing the email.

Open in new window

0
Beverley PortlockCommented:
You are attempting to use the mail function to send HTML formatted mail. To do this successfully you need to use something like the PEAR mail classes from www.pear.php.net

http://www.pear.php.net/package/Mail_Mime
http://www.pear.php.net/package/Mail

These would then be used as follows:
          $customerEmail  = "<html><head><title>$subject</title>".$this->styles."</head>";
          $customerEmail .= "<body>";
          if ( $subjHdr != "" )
               $customerEmail .= "<h3>$subjHdr</h3>";
          $customerEmail .= $mess . $attMess;
          $customerEmail .= "</body></html>";
 
          $mime->setHtmlBody($customerEmail);
          $body = $mime->get();
          $hdrs = $mime->headers($headers);
 
          $mail = &Mail::factory('mail');
 
          $result = ($mail->send($to, $hdrs, $body) == 1);

Open in new window

0
Richard KortsAuthor Commented:
To bportlock:

In the test file is my own email address. It sent it fine to me & I know 7 of the 10 names in the file received it too.

The email is formatted (html wise) correctly.

Whay is that?
0
Richard KortsAuthor Commented:
To hielo:

In the test file is my own email address. It sent it fine to me & I know 7 of the 10 names in the file received it too.

I realize the file is not "truly" csv, but it seems to work at least MOST of the time.

Why is that?
0
hieloCommented:
>>Why is that?
Like I said, "Other than that, it's possible the spam filters of the receipient's accounts are trashing the email."

If I were coding a spam filter, I would look for phrases like
"Holiday Gift"
"noreply@..."
"FREE"

These are all "spam" phrases/keywords. You are sending and advertisement. Why some get it and others don't? It all boils down to how good/strict the spam filters of the receipients are.

If they are all on the same company and some get it and other don't, if a spam filters "sees" the same email to may accounts, it may be cutting filtering the email after a certain number. After all, who is to say you are not sending the same advertisement to 5 or 50 or 500 or 5000 people within the same organization?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.