【问题标题】:Sending an email using WAMP and sendmail [duplicate]使用 WAMP 和 sendmail 发送电子邮件 [重复]
【发布时间】: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 访问。谁能帮我解决这个问题?

【问题讨论】:

    标签: php email sendmail


    【解决方案1】:

    Google 需要身份验证,因此需要用户名和密码。 You can see their configuration settings for sendmail here.

    配置中任何以; 分号开头的行都会被注释掉并且不会被处理。

    按照以下说明设置 SMTP 中继服务 发邮件。这些说明旨在与大多数 部署。

    不需要更改服务器超时。在 Sendmail 中, 服务器超时在 Timeout.datafinal 值中设置。默认情况下,它是 设置为一小时。如果 Timeout.datafinal 值已更改为 较低的值,将值提高到一小时。

    为 Sendmail 配置智能主机:

    将以下行添加到 /etc/mail/sendmail.mc 文件中: 定义(SMART_HOST',smtp-relay.gmail.com')

    停止并重新启动 sendmail 服务器进程。

    完成配置后, 发送测试消息以确认您的出站邮件正在流动。在 除了上面列出的服务器配置步骤,您可能还需要 如果其中任何一个在您的服务器上执行附加配置 以下是正确的:

    您单击允许发件人设置中的任何地址选项,然后 您从不属于您的域(例如 yahoo.com)发送邮件。你 发送没有“发件人”地址的邮件,例如未送达报告或 假期“不在办公室”通知。在这些情况下,您必须 配置您的邮件服务器以确保服务器正在使用 SMTP AUTH 作为注册的应用程序用户进行身份验证或提供一个 HELO 或 EHLO 命令中的域名。请参阅说明 在这里。

    【讨论】:

      猜你喜欢
      • 2015-08-22
      • 2017-01-20
      • 1970-01-01
      • 1970-01-01
      • 2010-12-31
      • 2018-07-22
      • 2013-11-22
      • 1970-01-01
      • 2010-12-10
      相关资源
      最近更新 更多