Вопрос

Я скачал последнее обновление Xampp, которое в значительной степени испортило мою старую конфигурацию. В какой -то момент я смог отправить Basic Mail () с 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