我尝试使用php mail()函数发送本地主机到我的yahoo电子邮件帐户的电子邮件,返回说我成功发送电子邮件,但没有收到任何电子邮件。我一直在阅读和尝试许多所谓的“简单方式”来发送电子邮件,但结果令人失望,没有一个适合我。以下是代码,配置和错误消息。有人可以用这个来启发我吗?谢谢。使用GMAIL邮件服务器在PHP中运行使用XAMMP的本地主机发送电子邮件
PHP代码
<?php
$to = '[email protected]';
$subject = 'Fake sendmail test';
$message = 'If we can read this, it means that our fake Sendmail setup works!';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)) {
echo 'Email sent successfully!';
} else {
die('Failure: Email was not sent!');
}
?>
配置为php.ini文件(我使用Gmail的邮件服务器)
@ gmail.comSMTP = smtp.gmail.com
SMTP_PORT = 587
sendmail_from = myemail sendmail_path =“\”C:\ xampp \ sendmail \ sendmail.exe \“-t”
sendmail_path =“\”
配置为sendmail.ini
在sendmail的错误日志smtp_server = smtp.gmail.com
SMTP_PORT = 587
smtp_ssl = TLS
error_logfile = error.log中
debug_logfile =
的debug.log auth_username = myemail @ gmail.com
auth_password = mypassword
[email protected]
错误消息端口587
13/10/02 13时36分41秒:必须首先发出STARTTLS命令。 k4sm129639pbd.11 - gsmtp
一个细节博客:http://goo.gl/O1zw89 –