Results 1 to 8 of 8

Thread: PHP mail() not working

  1. #1
    Guest

    Exclamation PHP mail() not working

    When i try to send an email through mail() in PHP it doesn't send email but sometimes when it sends an email it says that email is sent but i don't receive any email

  2. #2
    karl94 is offline AlterVista Staff
    Join Date
    Jan 2015
    Posts
    573

    Default

    Did you check the spam folder?

  3. #3
    Guest

    Default

    Yes , i have checked sir but still not working kindly see my issue.

  4. #4
    karl94 is offline AlterVista Staff
    Join Date
    Jan 2015
    Posts
    573

    Default

    Could you provide the code you are using? Did you try to send emails to a different email (of a different email provider)?

  5. #5
    Guest

    Default

    This code i m using sir:
    <?php
    $to="parretti.francescoit@gmail.com";
    $subject="My Subject";
    $message="My HTML Based Message";
    $header = "";
    $header .= "Reply-To: Francesco <francescoparretti@altervista.org>\r\n";
    $header .= "Return-Path: Francesco <francescoparretti@altervista.org>\r\n";
    $header .= "From: Francesco <francescoparretti@altervista.org>\r\n";
    $header .= "Organization: Francesco \r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: text/html; charset=utf-8\r\n";
    $header .= "X-Mailer: PHP/" . phpversion()."\r\n";
    $header .= "Content-Transfer-Encoding: 7bit\n\n";
    if (mail($to, $subject, $message, $header)) {
    echo "Message sent!";
    } else {
    echo "Message failed sending!";
    }

    ?>

  6. #6
    javelin is offline Junior Member
    Join Date
    Jan 2015
    Posts
    7

    Default

    I'm also having intermittent issues with the mail() function. Every time my script runs it claims the email has been successfully sent, however I rarely receive an email in my Inbox.

    Code snippet below:

    $to = "javelin***@iinet.net.au"; // Obfuscated email address
    $subject = "Javelin | " . _INPUT('name') . " has made contact";
    $message = stripslashes(commentCheck(_INPUT('comment'))) . "<br>";
    $header = "From: " . _INPUT('email') . "\r\n";
    $header .= "Content-type: text/html; charset=iso-8859-1\r\n";

    mail($to, $subject, $message, $header);
    echo "<p class=\"msg\">Thank you, " . _INPUT('name') . ". Your message has been successfully sent. You should receive a response shortly.</p>\n";

    Any non-standard functions are simply there to validate the user's form data.
    Last edited by javelin; 05-27-2015 at 01:15 PM.

  7. #7
    saitfainder's Avatar
    saitfainder is offline AlterVista Staff
    Join Date
    Feb 2010
    Posts
    300

    Default

    Quote Originally Posted by javelin View Post
    I'm also having intermittent issues with the mail() function. Every time my script runs it claims the email has been successfully sent, however I rarely receive an email in my Inbox.
    You mail has been probably blocked by a antispam filter.

    I see that you're sending an HTML mail, but the content is not a complete HTML page (at least <HTML> and <BODY> are missing). Try to send a more compliant HTML page.

    And when you set a Content-Type header you should add a MIME-Version header to be compliant with specifications.
    "Over thinking, over analyzing separates the body from the mind."

  8. #8
    javelin is offline Junior Member
    Join Date
    Jan 2015
    Posts
    7

    Default

    Quote Originally Posted by saitfainder View Post
    You mail has been probably blocked by a antispam filter.

    I see that you're sending an HTML mail, but the content is not a complete HTML page (at least <HTML> and <BODY> are missing). Try to send a more compliant HTML page.

    And when you set a Content-Type header you should add a MIME-Version header to be compliant with specifications.
    Thanks for the heads up. I made the changes - which worked for a day - and now emails aren't working again. Is there any way of viewing logs, etc. to help identify the cause of the problem?

Posting Permissions

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

SEO by vBSEO