?
Solved

Automated Emailing

Posted on 2008-11-07
5
Medium Priority
?
227 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Richard Korts
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22906627
>>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
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 22906686
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
 

Author Comment

by:Richard Korts
ID: 22906854
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
 

Author Comment

by:Richard Korts
ID: 22906876
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
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22906984
>>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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question