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
.