2

The below code shows "Message sent successfully..." but mail sent out doesn't receives in inbox or spam folder of receiver.

<?php
    $to = "rcvr@example.com";
    $subject = "This is subject";

    $message = "<b>This is HTML message.</b>";
    $message .= "<h1>This is headline.</h1>";

    $header = "From:mymailid@gmail.com \r\n";
    $retval = mail ($to,$subject,$message,$header);
    if( $retval == true )
    {
    echo "Message sent successfully...";
    }
    else
    {
    echo "Message could not be sent...";
    }
?>

I've changed [mail function] in php.ini as like this

[mail function]
SMTP = smtp.gmail.com
smtp_port = 587
sendmail_from = mymailid@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

And [sendmail] in sendmail.ini like this

smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
pop3_server=
pop3_username=
pop3_password=
force_recipient=
hostname=

auth_username=mymailid@gmail.com
auth_password=mymailid_pass
force_sender=mymailid@gmail.com

So everything is fine and $retval returns true and echo 'Message sent successfully...' but receiver don't get it at his inbox or in spam. I also enabled imap in gmail settings->forwarding and pop/imap.

Vilas
  • 837
  • 2
  • 15
  • 41

1 Answers1

0
<?php
    $to = "rcvr@example.com";
    $subject = "This is subject";

    $message = "<b>This is HTML message.</b>";
    $message .= "<h1>This is headline.</h1>";

    $header = "From:mymailid@gmail.com \r\n";
    $retval = mail($to,$subject,$message,$header);
    if(isset($retval))//change
    {
        echo "Message sent successfully...";
    }
    else
    {
        echo "Message could not be sent...";
    }
?>

and comment the below line in php.ini

sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

Read this answer to Config Your localserver

Community
  • 1
  • 1
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
  • in my `php.ini` line `sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"` not present only `sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"` present and I comment this line but still not working – Vilas Sep 22 '15 at 10:42
  • not that line. there is another line. Search it once – Abdulla Nilam Sep 22 '15 at 10:45
  • No. I searched but there is only `sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"` line present – Vilas Sep 22 '15 at 10:59