• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

email not delivered

I'm generating emails via php.

Recipients are NOT receiving.

Note code in code window. Note the $tostr. Note the blank space between the two addresses.

In the email message, see following:

To: ibsanwal@gmail.com ; dnicholson@fulbright.com

The recipients are separated by <space>;<space>.

I can't IMAGINE that's a problem, but I can't see what else it can be.

Can someone help?
<?
function convdate($x) {
	if ($x != "" && substr($x,0,10) != "0000-00-00") {
		$fd = substr($x,5,2) . "/" . substr($x,8,2) . "/" . substr($x,0,4);
	} else {
		$fd = "";
	}		
	return $fd;
}
$today = date('Y') . "-" . date('m') . "-" . date('d');
// test expiration emails
// expiring in future or today
$fsubj = "WHA Membership Expiring";
$fmsg1 = "Thank you for your membership in Women in Health Administration of Southern California (WHA)! We hope you have found your membership rewarding, and we look forward to your participation in WHA in the upcoming year.<br><br>";
$fmsg2 = "This email is to let you know that your membership is expiring ";
$fmsg3 = "We hope you will consider renewing for another year. You can renew your membership online at http://whasocal.org/memb_renewal.php (log in using your email address and password). You can also renew by mailing a check or money order (Payable to: WHA) for ";
$fmsg4 = "to the following address as soon as possible:<br><br>";
$fmsg4 = $fmsg4 . "Women in Health Administration<br>PO Box 77932<br>Corona, CA 92877-0131<br><br>";
$fmsg4 = $fmsg4 . "Please include a copy of this email with your payment, to ensure prompt processing.<br><br>";
$fmsg4 = $fmsg4 . "As you know, WHA membership includes, but is not limited to, the following benefits: networking opportunities, discounted program registration fees, job opportunities, and our Executive Forum newsletter.<br><br>";
$fmsg4 = $fmsg4 . "If you have any questions or comments, please contact us at contact@whasocal.org.<br><br>Thanks again!<br><br>Women in Health Administration of Southern California<br>http://www.whasocal.org";
// expired in past
$psubj = "WHA Membership Expired";
$pmsg1 = "This email is to let you know that your membership in Women in Health Administration of Southern California (WHA) expired on ";
$pmsg2 = "We hope you will consider renewing for another year - you can renew online at http://whasocal.org/memb_renewal.php (log in using your email address and password).  As you know, WHA membership includes, but is not limited to, the following benefits: networking opportunities, discounted program registration fees, job opportunities, and our Executive Forum newsletter.";
$pmsg3 = "We hope you found your membership rewarding, and we look forward to your participation in WHA in the upcoming year, either as a member or a guest at one of our events.";

$pmsg4 = "In case you choose to not renew your membership, as part of our ongoing efforts to identify areas for improvement, we would appreciate if you could spare a few minutes to complete our short exit survey: <a href='http://www.surveymonkey.com/s/CG7NB83'>http://www.surveymonkey.com/s/CG7NB83</a><br><br>";
$pmsg5 = "Thank you in advance for your help. We wish you the best of luck in all of your future endeavors.<br><br>";

$pmsg5 = $pmsg5 . "If you have any questions or comments, please contact us at contact@whasocal.org.<br><br>Women in Health Administration of Southern California<br>http://www.whasocal.org";
$exmsg = "We would appreciate if you could spare a few minutes to complete our short exit survey: http://www.surveymonkey.com/s/CG7NB83<br><br>"; 
$ttdy = mktime(0,0,0, date('m'), date('d'), date('Y'));
$tdp14 = $ttdy + 86400*14;
$gd14 = getdate($tdp14);
$d14 = $gd14['mon'] . "/" . $gd14['mday'] . "/" . $gd14['year'];
$tdp30 = $ttdy + 86400*30;
$gd30 = getdate($tdp30);
$d30 = $gd30['mon'] . "/" . $gd30['mday'] . "/" . $gd30['year'];
// 30 days ago
$tdm30 = $ttdy - 86400*30;
$gdm30 = getdate($tdm30);
$dm30 = $gdm30['mon'] . "/" . $gdm30['mday'] . "/" . $gdm30['year'];
// 60 days ago
$tdm60 = $ttdy - 86400*60;
$gdm60 = getdate($tdm60);
$dm60 = $gdm60['mon'] . "/" . $gdm60['mday'] . "/" . $gdm60['year'];
// 91 days ago
$tdm91 = $ttdy - 86400*91;
$gdm91 = getdate($tdm91);
$dm91 = $gdm91['mon'] . "/" . $gdm91['mday'] . "/" . $gdm91['year'];
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@wha.org\r\n";	
$headers .= 'Bcc: richard@rkassociates.com' . "\r\n";	
$tostr = "ibsanwal@gmail.com, dnicholson@fulbright.com";	
//$tostr = "richard@rkassociates.com";
$subj = $fsubj;
$msg = $fmsg1;
$msg = $msg . $fmsg2 . " in 30 days.<br><br>";
$msg = $msg . "Name: Mary Smith<br>Email: marysmith@aol.com<br>Membership Type: Active<br>Expiration Date: " . $d30 . "<br><br>";
$msg = $msg . $fmsg3 . "$90 " . $fmsg4;
// 30 days out
$res30 = mail($tostr, $subj, $msg, $headers);
echo "30 days sent, res30 = " . $res30 , "<br>";
sleep(2);
$msg = $fmsg1 . $fmsg2 . " in 14 days.<br><br>";
$msg = $msg . "Name: Mary Smith<br>Email: marysmith@aol.com<br>Membership Type: Active<br>Expiration Date: " . $d14 . "<br><br>";
$msg = $msg . $fmsg3 . "$90 " . $fmsg4;
// 14 days out
$res14 = mail($tostr, $subj, $msg, $headers);
echo "14 days sent, res14 = " . $res14 , "<br>";
sleep(2);
$msg = $fmsg1 . $fmsg2 . " today. <br><br>";
$msg = $msg . "Name: Mary Smith<br>Email: marysmith@aol.com<br>Membership Type: Active<br>Expiration Date: " . convdate($today) . "<br><br>";
$msg = $msg . $fmsg3 . "$90 " . $fmsg4;
// Today
$res0 = mail($tostr, $subj, $msg, $headers);
echo "Today sent, res0 = " . $res0 , "<br>";
sleep(2);
$subj = $psubj;
$msg = $pmsg1 . $dm30 . "<br><br>";
$msg = $msg . $pmsg2 . $pmsg3 . $pmsg4 . $pmsg5;
// 30 days ago
$resm30 = mail($tostr, $subj, $msg, $headers);
echo "30 days past sent, resm30 = " . $resm30 , "<br>";
sleep(2);
$msg = $pmsg1 . $dm60 . "<br><br>";
$msg = $msg . $pmsg2 . $pmsg3 . $pmsg4 . $pmsg5;
// 60 days ago
$resm60 = mail($tostr, $subj, $msg, $headers);
echo "60 days past sent, resm60 = " . $resm60 , "<br>";
sleep(2);
$msg = $pmsg1 . $dm91 . "<br><br>";
$msg = $msg . $exmsg . $pmsg5;
// 91 days ago
$resm91 = mail($tostr, $subj, $msg, $headers);
echo "91 days past sent, resm91 = " . $resm91 , "<br>";
exit;
?>

Open in new window

0
Richard Korts
Asked:
Richard Korts
  • 2
  • 2
  • 2
  • +3
2 Solutions
 
Aaron TomoskyTechnology ConsultantCommented:
Does it work with just one email address?
0
 
psimationCommented:
Have you eliminated obvious things first; ie, can your server send out simpler emails using mail() at all?

If a test script with a very simple mail() also fails, then your server may not be configured correctly.

You can also use PHPMailer class instead of mail().

You can download PHPMailer class here: http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/ 

Plenty of examples of using the class  here: http://phpmailer.worxware.com/index.php?pg=exampleasmtp
 
0
 
psimationCommented:
PS - you DID state in your question that you separate by ; , but in your code it is not:

$tostr = "ibsanwal@gmail.com, dnicholson@fulbright.com";

You must separate by " ; " and also make sure you have a ";" AFTER the last address in your string as well. if you can, don't put spaces between the address and the trailing ";" but it shouldn't matter.
 
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Dave BaldwinFixer of ProblemsCommented:
On this page http://us3.php.net/manual/en/function.mail.php and every page I've seen, 'to' addresses is a comma-delimited list with no comma at the end.

@rkorts, does the demo I posted for you work with a single address?
0
 
Richard KortsAuthor Commented:
To all,

It works with a single email address if it's mine.

I have sent HUNDREDS of emails from this server via php mail; no problem.

I know that the recipient email addresses are correct. I use them ALL the time with manually composed emails with no problem.

Note that I am bcc'd. I got ALL the bcc's.

My suspicion is the blank space after the comma after the first name. I'm going to test it with no space.

Note to psianimation: if you separate by ";" in php mail, it DOES NOT work. I know that from an ee  question yesterday. For php mail() function, you MUST use commas. And I never heard of a comma at the end.
0
 
Dave BaldwinFixer of ProblemsCommented:
Then it's either the format or the server.  If you are using the simple SMTP server with IIS, you may have to put the extra 'to' addresses in the 'Cc: field in the 'headers'.
0
 
Ray PaseurCommented:
Email is a brittle thing and there are lots of reasons why email messages might not get delivered.  Servers and spam filters can be involved.  Client email reader programs can have automated settings that may work against you.  So it could literally be hundreds of things in play.  Fortunately, there is a company that dedicates its existence to getting your email messages to go through.  Learn about ConstantContact.com and see if that's the solution you need.  Since 2008 I have not added any email functionality to any client site except through Constant Contact.  They are dependable, embarrassingly inexpensive and they have saved me countless hours of non-value-added time working on frustrating problems just like this one you are wrestling with right now.  Plus my customers love the results and are happy to pay for the results.  It's a win-win situation.

That aside, you might want to take a moment to read this article.  It will make the DATETIME processing in your PHP scripts much easier!
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

Best regards, ~Ray
0
 
Ray PaseurCommented:
Notwithstanding our Author's assertion that  No answer solves the problem, there is, in fact, a solution and the solution is to use a professionally hosted email service.  Sorry if it is not the answer you want, but it is the answer you get, and you get this answer for a very good reason.  I recommend ConstantContact.com because it solves this problem and many more.  I won't be addressing any more of these nebulous questions about email failures.  There are too many things that can go wrong with email and there are amazingly easy and inexpensive solutions that cover the breadth of the problems.  I know from personal experience that ConstantContact.com works.  Until our Asker demonstrates that ConstantContact.com has been tried and shown to be useless, it is the only answer I will offer for these sorts of questions, full stop.
0
 
Richard KortsAuthor Commented:
All right, I will cancel the "delete question" request.
0
 
hieloCommented:
try adding a To header:
      

...
$tostr = "ibsanwal@gmail.com, dnicholson@fulbright.com";	
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@wha.org\r\n";	
$headers .= "To: {$tostr}\r\n";	
$headers .= 'Bcc: richard@rkassociates.com' . "\r\n";
...

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now