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

我进行了一些研究,每个人都推荐Zend或Phpmailer。我尝试了phpmailer,这给我带来了一个错误,说Cound没有得到回应。

用我的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归因
不隶属于 StackOverflow
scroll top