SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    E-mail not being sent

    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...

    PHP Code:
        // ******************************
        // Create New-Comment E-mail.        *
        // ******************************

        
    $title 'Re: New comment on "' $articleHeading '" ' rand(51000) . "\n";

        
    $body "<p>Dear $subscriberFirstName,</p>\n";
        
    $body .= "<p>The user, \"$commenterUsername\", has posted a new comment to the article:<br />\n\t";
        
    $body .= "<span class='indent'>\"$articleHeading\"</span>\n";
        
    $body .= "<p>To view this article, <a href='/articles/" $articleSlug "'>click here</a></p>\n";
        
    $body .= "<p>To view this comment, <a href='/articles/" $articleSlug "#comment_" $commentID "'>click here</a></p>\n";
        
    $body .= "<p>Sincerely,<br /><br /><br />\n\n\n";
        
    $body .= "<p>Customer Service</p>";

        
    $headers  "From: admin@MySite.com <admin@MySite.com\r\n";
        
    $headers .= "MIME-Version: 1.0\r\n";
        
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    //echo $subscriberEmail . "<br /><br />";
    //echo $title;
    //echo $body;
    //echo $headers;
    //exit();

        
    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??

    Thanks,


    Debbie

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    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.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    Well for starters, i spy a missing > at the end of your from header....
    Good catch!

    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.


    Debbie

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    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.

  5. #5
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Maui, HI
    Posts
    211
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •