繁体   English   中英

使用phpmailer和XAMPP调试PHP邮件到Yahoo电子邮件

[英]Debugging PHP Mail with phpmailer and XAMPP to Yahoo email

我已经下载了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?

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

暂无
暂无

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

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