繁体   English   中英

XAMPP sendmail无法通过Gmail发送邮件

[英]XAMPP sendmail won't send mail via Gmail

这个问题已经被反复询问,但是似乎没有一个解决方案:

我正在运行此测试php文件:

<?php

$to = "email@gmail.com";
$subject = "Test";
$message = "This is a test";
$from = "From: email@gmail.com";


if(mail($to, $subject, $message, $from)) {
echo 'Email sent successfully!';
} else {
die('Failure');
}
?>

php.ini更改以下行后:

[mail function]

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

以及sendmail.ini这些行:

smtp_server=smtp.gmail.com
smtp_port=587 ;I've tried 465 but gmail doesn't seem to like to connect to SSL
auth_username=email@gmail.com
auth_password=password

邮件发送失败,调试日志如下:

15-02-21 13:35:59 ** --- MESSAGE BEGIN ---
15-02-21 13:35:59 ** To: email@gmail.com
15-02-21 13:35:59 ** Subject: Test
15-02-21 13:35:59 ** From: email@gmail.com
15-02-21 13:35:59 ** 
15-02-21 13:35:59 ** This is a test
15-02-21 13:35:59 ** --- MESSAGE END ---
15-02-21 13:36:01 ** Connecting to smtp.gmail.com:587
15-02-21 13:36:02 ** Connected.
15-02-21 13:36:02 << 220 mx.google.com ESMTP z10sm6176887pas.18 - gsmtp<EOL>
15-02-21 13:36:02 >> EHLO Lenovo-PC<EOL>
15-02-21 13:36:02 << 250-mx.google.com at your service, []<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
15-02-21 13:36:02 ** Authenticating as email@gmail.com
15-02-21 13:36:02 >> STARTTLS<EOL>
15-02-21 13:36:02 << 220 2.0.0 Ready to start TLS<EOL>
15-02-21 13:36:02 >> QUIT<EOL>
15-02-21 13:36:02 << bunch of special characters   
15-02-21 13:36:02 ** Disconnected.
15-02-21 13:36:02 ** Disconnecting from smtp.gmail.com:587
15-02-21 13:36:02 ** Disconnected.
15-02-21 13:36:02 ** Disconnected.
15-02-21 13:36:02 ** Connection Closed Gracefully.

任何帮助表示赞赏。

没关系,我想通了...在Windows 8中,您需要更改sendmail.exe的兼容模式(以及在管理员中运行它):

1)左键单击sendmail.exe并转到属性2)单击兼容性选项卡,然后单击更改所有用户的设置3)将兼容模式设置为Windows XP(Service Pack 3)4)单击复选框以管理员身份运行此程序

希望对别人有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM