I just added a feature to my website which e-mails all Members who have subscribed to an Article Thread (e.g. "Postage Meters Can Save You Money") when other Members post new Comments.
Unfortunately, my test data is not sending me an e-mail.
Here is my e-mail specific code...
// Create New-Comment E-mail. *
$title = 'Re: New comment on "' . $articleHeading . '" ' . rand(5, 1000) . "\
$body = "<p>Dear $subscriberFirstName,</p>\
$body .= "<p>The user, \\"$commenterUsername\\", has posted a new comment to the article:<br />\
$body .= "<span class='indent'>\\"$articleHeading\\"</span>\
$body .= "<p>To view this article, <a href='/articles/" . $articleSlug . "'>click here</a></p>\
$body .= "<p>To view this comment, <a href='/articles/" . $articleSlug . "#comment_" . $commentID . "'>click here</a></p>\
$body .= "<p>Sincerely,<br /><br /><br />\
$body .= "<p>Customer Service</p>";
$headers = "From: admin@MySite.com <admin@MySite.com\\r\
$headers .= "MIME-Version: 1.0\\r\
$headers .= "Content-Type: text/html; charset=ISO-8859-1\\r\
//echo $subscriberEmail . "<br /><br />";
mail($subscriberEmail, $title, $body, $headers);
When I uncomment the echoes above, I am getting expected values in each variable, so I would expect my e-mail to work?! :-/
I also added a random # to the Subject Line as it makes Gmail less inclined to think this is spam.
**NOTE: I am trying to run this script from my laptop, so I don't have a valid Email/Domain/IP in my Dev Environment, but I haven't really had any issues on a separate script which e-mails me every time there is a System Error, so I would expect this to work as well...
I also tried changing where the test "New Comment" e-mail goes, routing it to my ATT e-mail, thinking it is less picky than Gmail??
Is my code wrong, or am I getting treated as SPAM??
Well for starters, i spy a missing > at the end of your from header....
If that doesnt work, try removing the \r's from your headers entirely.
I don't think that was the issue.
It appears that all of the e-mail services were questioning whether my dev-generated e-mail were spam or not.
I started getting e-mails a few hours later on Gmail, although they never even showed up in my spam folder with AT&T?!
Thanks for trying to help.
Not sure if this applies in your case, but I sometimes have problems if the email address I enter in the form is the same email address to which the message is to be sent. Best just to enter a fake email address into the form for testing porpoises.
Apparently, some larger email providers will mark messages as spam if they don't have a valid Return-Path header. Check out this comment in the manual: http://us2.php.net/manual/en/function.mail.php#107321
This topic is now closed. New replies are no longer allowed.