简体   繁体   English

XAMPP sendmail无法通过Gmail发送邮件

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

This question has been asked repeatedly but none seem to have a solution: 这个问题已经被反复询问,但是似乎没有一个解决方案:

I'm running this test php file: 我正在运行此测试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');
}
?>

after changing the following lines in php.ini : 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"

as well as these lines in sendmail.ini : 以及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

Mail fails to send and the debug log is as follows: 邮件发送失败,调试日志如下:

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.

Any help is appreciated. 任何帮助表示赞赏。

Never mind I figured it out... in Windows 8 you are required to change sendmail.exe's compatibility mode (as well as run it in administrator): 没关系,我想通了...在Windows 8中,您需要更改sendmail.exe的兼容模式(以及在管理员中运行它):

1) left click sendmail.exe and go to properties 2) click compatibility tab then click change settings for all users 3) set compatibility mode to Windows XP (Service Pack 3) 4) click the check box for run this progrma as an administrator 1)左键单击sendmail.exe并转到属性2)单击兼容性选项卡,然后单击更改所有用户的设置3)将兼容模式设置为Windows XP(Service Pack 3)4)单击复选框以管理员身份运行此程序

Hope that helps someone else. 希望对别人有帮助。

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

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