0

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

4

1 回答 1

0

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

于 2010-12-07T18:52:22.940 回答