【发布时间】:2014-11-12 04:32:38
【问题描述】:
我在 Windows 8 上安装了 WAMP,并尝试使用 sendmail 发送电子邮件。 该代码返回“已发送电子邮件”,但是,testemail 帐户在其收件箱或垃圾邮件文件夹中未收到任何电子邮件。
这是我的 sendmail.ini 文件。(我已尝试 25,587,465 用于 smtp_port 和 ssl,blank,none,tls 用于 smtp_ssl)
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
auth_username=myaccount@gmail.com
auth_password=mypassword
hostname=localhost
这是php.ini文件的【邮件功能】。
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP =localhost
; http://php.net/smtp-port
;smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = myaccount@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="c:\wamp\sendmail\sendmail.exe -t -i"
这是我用于发送电子邮件的 php 文件
<?php
$to = 'testemailaccount@live.com';
$subject='testing';
$message = 'This is a test';
$headers = 'From: myaccount@gmail.com' . "\r\n" .
'Reply-To: myaccount@gmail.com' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to,$subject,$message,$headers))
{
echo "email sent";
}
else
{
echo "Invalid Email";
}
?>
这是我在调试日志文件中得到的内容
14/11/12 12:25:11 ** --- MESSAGE BEGIN ---
14/11/12 12:25:11 ** To: testemailaccount@live.com
14/11/12 12:25:11 ** Subject: testing
14/11/12 12:25:11 ** X-PHP-Originating-Script: 0:email.php
14/11/12 12:25:11 ** From: myaccount@gmail.com
14/11/12 12:25:11 ** Reply-To: myaccount@gmail.com
14/11/12 12:25:11 ** MIME-Version: 1.0
14/11/12 12:25:11 ** Content-type: text/html; charset=iso-8859-1
14/11/12 12:25:11 ** X-Mailer: PHP/5.3.13
14/11/12 12:25:11 **
14/11/12 12:25:11 ** This is a test
14/11/12 12:25:11 ** --- MESSAGE END ---
14/11/12 12:25:11 ** Connecting to smtp.gmail.com:25
14/11/12 12:25:12 ** Disconnected.
14/11/12 12:25:12 ** Disconnected.
14/11/12 12:25:12 ** Socket Error # 10061<EOL>Connection refused.
我尝试在谷歌上搜索解决方案,并将我的 sendmail.exe 设置为以管理员权限运行。我还在 myaccount@gmail.com 上启用了 IMAP 访问。谁能帮我解决这个问题?
【问题讨论】: