【问题标题】:Debugging PHP Mail with phpmailer and XAMPP to Yahoo email使用 phpmailer 和 XAMPP 调试 PHP 邮件到 Yahoo 电子邮件
【发布时间】:2011-05-21 18:25:11
【问题描述】:

我已经下载了 XAMPP 的最新更新,它几乎搞乱了我的旧配置。我曾一度能够使用 PHP 发送基本的 mail(),但一旦我更新它就停止了。

我研究了一下,每个人都推荐 Zend 或 PHPMailer。我尝试了 PHPMailer,它返回了一个错误,说无法得到响应。

弄乱了我的 php.ini 并将套接字超时从 60 增加到 120。这不起作用,所以我尝试向自己发送测试邮件。

Failed to connect to mailserver at "localhost" port 25,
verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

所以,我检查了 php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25;

;Add X-PHP-Originating-Script: that will 
;include uid of the script followed by the filename

好的,所以我想,“我将只使用 PHPMailer 来包含 SMTP 和端口:

require_once('../class.phpmailer.php');

$mail             = new PHPMailer();        // defaults to using php "mail()";

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP();                            // telling the class to use SMTP
$mail->AddReplyTo("noreply@randomcompany.com","Company Name Here");
$mail->Host       = "localhost";           // SMTP server
$mail->SMTPDebug  = 2;                      // enables SMTP debug information (for testing)
$mail->Port       = 25;                     // set the SMTP port for the GMAIL server


$mail->From       = "noreply@randomcompany.com";
$mail->FromName   = "Company Name Here";

$address = "test@yahoo.com";
$mail->AddAddress($address, "Hello to myself for testing!");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

//$mail->AddAttachment("images/phpmailer.gif");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

mail.add_x_header = Off 

上面说:

SMTP -> ERROR: Failed to connect to server: 
A connection attempt failed because the connected 
party did not properly respond after a period of 
time, or established connection failed because 
connected host has failed to respond. (10060)

SMTP Error: Could not connect to SMTP host. 
Mailer Error: SMTP Error: Could not connect to SMTP host.

水星说:

This message is sending now ...

Error! The message was not successfully sent!

Zurück zum Formular

花了那么多时间,我现在想知道,是我的代码、php.ini、phpmailer 还是 Yahoo?

【问题讨论】:

    标签: php email phpmailer yahoo-mail


    【解决方案1】:

    我认为您缺少邮件服务器。或者你有一个运行在 25 端口的本地邮件服务器? ;-) 但是 XAMPP 带来了一个名为 Mercury 的邮件服务器 - 所以...启动它并玩得开心 ;-)。

    【讨论】:

    • 你提醒了我,所以我启动了它,但我仍然遇到同样的错误:(
    • 您无法连接?检查您的防火墙设置。尝试暂时禁用它并重试执行脚本。
    • 嗯,我正在使用 McAfee,看起来它不会让我关闭它。我确实为端口 25 创建了一条规则,并为 Apache 提供了完整的互联网权限。但是,仍然无法发送邮件。
    • Mercury 需要完整的“出站”权限。 PHPMailer 向Mercury 发出请求,该请求连接到在域的 MX 记录中返回的邮件服务器(= 大部分 Internet ;))。
    • 谢谢!我从来没有想过将 Mercury.exe 添加到防火墙权限!
    猜你喜欢
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-22
    • 2018-10-16
    • 2016-08-03
    • 1970-01-01
    相关资源
    最近更新 更多