i am using the following code to sendmail using php mail() function.but it does not work.
$msg = "This is demo mail";
// send email
$headers = 'From:no-reply@example.com' . "\r\n" ;
$headers .='Reply-To: '. $to . "\r\n" ;
$headers .='X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if(mail("me@mail.com","Test",$msg,$headers)) {
echo('<br>'."Email Sent ".'</br>');
}
else
{
echo("<p>Email Message delivery failed...</p>");
}
when i check in mail.log file the error is like following:
Return-Path: <www-data@localhost.localdomain>
Received: from localhost.localdomain (localhost [127.0.0.1])
by localhost.localdomain with ESMTP id
for <me@mail.com>; Tue, 21 Nov 2016 12:54:46 GMT
Received: (from www-data@localhost)
by localhost.localdomain (8.14.4/8.14.4/Submit) id id;
can anyone know why return path is set to "www-data@localhost.localdomain"?
how can i change it? the problem that i am facing is for yahoo and hotmail account as not receiving emails.
i have configured my php.ini like this to send mail:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog (Event Log on NT, not valid in Windows 95).
;mail.log = syslog