我尝试了很多东西,但仍然无法从我当地的主机发送电子邮件!
我的php.ini文件如下所示:
[mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = brothersrbin@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
和我的senmail.ini文件如下所示:
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=brothersrbin@gmail.com
auth_password=my-gmail-password //my real pass for this email
force_sender=brothersrbin@gmail.com
我的php代码如下:
$to = "poznan.milan@gmail.com";
$subject = "REsttujte vas password";
$message = "This is simple text message.";
$header = "From:brothersrbin@gmail.com \r\n";
$retval = mail($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
有人可以帮助我。这里有什么问题?你可以给我另一个解决方案吗?