我在 XAMPP 中有以下配置设置:
在php.ini
:
[mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = *******@gmail.com
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
我也在php_openssl.dll
这里激活了扩展。
在sendmail.ini
:
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=*****@gmail.com
auth_password=******
force_sender=************@gmail.com
smtp_ssl=auto
但是,我无法使用此配置发送任何邮件。这是Debug.log
输出:
19/06/15 00:01:39 ** --- MESSAGE BEGIN ---
19/06/15 00:01:39 ** To: ********@gmail.com
19/06/15 00:01:39 ** Subject: Hello from XAMPP!
19/06/15 00:01:39 ** From: *****@gmail.com
19/06/15 00:01:39 **
19/06/15 00:01:39 ** This is a test
19/06/15 00:01:39 ** --- MESSAGE END ---
19/06/15 00:01:40 ** Connecting to smtp.gmail.com:587
19/06/15 00:01:41 ** Connected.
19/06/15 00:01:44 << 220 smtp.gmail.com ESMTP r88sm6899147pjb.8 - gsmtp<EOL>
19/06/15 00:01:44 >> EHLO ASUS<EOL>
19/06/15 00:01:44 << 250-smtp.gmail.com at your service, [103.220.204.137]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
19/06/15 00:01:44 ** Authenticating as ******@gmail.com
19/06/15 00:01:44 >> STARTTLS<EOL>
19/06/15 00:01:45 << 220 2.0.0 Ready to start TLS<EOL>
19/06/15 00:01:45 >> QUIT<EOL>
19/06/15 00:01:45 <<
出于某种原因,它是直接进入QUIT<EOL>
之后STARTTLS<EOL>
而不是身份验证命令。在命令之后的响应中也有很多垃圾输出QUIT<EOL>
。
这是垃圾输出的快照: debug.log
邮件发送脚本如下:
<?php
$to = '*******@gmail.com';
$subject = 'Hello from XAMPP!';
$message = 'This is a test';
$headers = "From: ******@gmail.com\r\n";
if (mail($to, $subject, $message, $headers)) {
echo "SUCCESS";
} else {
echo "ERROR";
}
总是返回错误。
我该如何解决这个问题?相同的配置适用于我朋友的两台机器。