我试着用php mail()函数从本地主机发送一封电子邮件到我的Yahoo电子邮件帐户,返回说我成功地发送了电子邮件,但是我没有收到任何电子邮件。我一直在阅读和尝试许多所谓的“简单的方式”发送电子邮件,但结果是令人失望的,他们都不适合我。下面是代码、配置和错误消息。有人能用这个启发我吗?谢谢。
PHP代码
<?php
$to = 'myemail@yahoo.com';$subject = 'Fake sendmail test';
$message = 'If we can read this, it means that our fake Sendmail setup works!';$headers = 'From: myemail@egmail.com' . "\r\n" .
'Reply-To: myemail@gmail.com' . "\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邮件服务器)
SMTP=smtp.gmail.com
SMTP端口=587
sendmail_from=mymail@gmail.com
sendmail_path=“\”C:\xampp\sendmail\sendmail.exe\“-t”
sendmail.ini配置
SMTP_server=smtp.gmail.com
SMTP端口=587
SMTP_SSL=TLS
Error_logfile=error.log
DEBUG_LOGfile=调试器
Auth_username=myemail@gmail.com
Auth_Password=mypassword
强制发件人=mymail@gmail.com
端口587的Sendmail错误日志中的错误消息
13/10/02 13:36:41:必须首先发出STARTTLS命令。k4sm129639pbd.11-gsmtp