Web Analytics Made Easy -
StatCounter php mail() is not sending - CodingForum

Announcement

Collapse
No announcement yet.

php mail() is not sending

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php mail() is not sending

    My php mail() is not sending and cant figure out why.. I have other scripts on the same domain and they send fine using mail() so its not a mail() issue i dont believe. I also checked all the vars and they are have the proper data. I even checked the CONSTANTS and they also have the proper value.

    But when i display $was_sent, it shows a blank page, not true and not false. And there are no server errors. So im wondering what could be the issue.

    in this test it always comes back 'no'


    The headers are loaded also..

    MIME-Version: 1.0
    Content-type: text/plain; charset=iso-8859-1
    X-Priority: 3
    X-MSmail-Priority: Normal
    X-mailer: php/7.2.31
    From: [email protected]


    Code:
    $memberemail = "[email protected]";
    $finalmess = "hey this is a test and we are testing this email process";
    $sitefrom = " ".CUSTOMERSERVICE_EMAIL; //keep leading space
    $from_email = CUSTOMERSERVICE_EMAIL; //reply to
    $subject = "Test Subject Request;
    
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "X-MSmail-Priority: Normal\n";
    $headers .= "X-mailer: php/".phpversion()."\n";
    $headers .= "From: $from_email\n";
    $extraparam ="-f $from_email";
    
    $was_sent = mail($memberemail, $subject, $finalmess, $headers, $extraparam);
    
    if($was_sent)
    {
       echo "<pre>";
       echo "yes";
       exit;
    }
    
    echo "<pre>";
    echo "no";
    exit;
    Any idea on what the issue may be?

    Thanks

    UPDATE: i got it.. turns out it was a combo of a small typo and also this:

    If your script uses PHP mail() function, you have to configure the From field of the form with an email account that was created in cPanel, is hosted on our server and has Local Mail Exchanger.


    Last edited by durangod; Jul 3, 2020, 09:08 PM.
    If a php file only has php code within it you do not need to use the closing php tag
    A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
    durangod is short for durango dave

  • #2
    Have you checked your sendmail settings? (https://www.php.net/manual/en/mail.requirements.php)

    But when i display $was_sent, it shows a blank page, not true and not false.
    This is typical for a fatal error, please consult your error logs.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

    Comment


    • #3
      Dormilich Thanks yes it was a typo and i had to change the email address to meet my hosting requirements. I want to give my customers two choices, php mail unsecure and then SMTP with phpMailer that i a currently setting up.
      If a php file only has php code within it you do not need to use the closing php tag
      A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
      durangod is short for durango dave

      Comment

      Working...
      X