Не могу отправить письмо с домашнего сервера

Недавно я решил перенести свой сайт с godaddy.com на мой домашний сервер … все прошло на удивление гладко, за исключением того, что я не смог доставить ни одной электронной почты! Я использую виртуальную машину с последней установленной версией Debian. На хост-компьютере работает Windows Server 2012 R2 Standard. Вот список вещей, которые я уже пробовал:

  • Отключены все брандмауэры (ВМ, Хост, Маршрутизатор)
  • Пробовал разные почтовые программы: sendmail, exim и др

Я вижу сообщения в очереди, но они остаются там до тех пор, пока я не получу сообщение об истечении времени ожидания.

Вот код для страницы тестовой почты, которую я настроил:

    <?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
*/

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('America/New_York');

require 'PHPMailer/PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 4;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server

$mail->Host = gethostbyname('smtp.gmail.com');
// use
// $mail->Host = gethostbyname('smtp.gmail.com'); was: $mail->Host = 'smtp.gmail.com';
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "correct_username";

//Password to use for SMTP authentication
$mail->Password = "correct_password";

//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'Homeworth 1 2 3');

//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'Michael Rosenbaum');

//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'Mikey Router');

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('PHPMailer/examples/contents.html'), dirname(__FILE__));

//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';

//Attach an image file
$mail->addAttachment('PHPMailer/examples/images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>

И вот результат, когда я запускаю его:

Connection: opening to 74.125.25.108:587, timeout=300, options=array ()
Connection: opened
SMTP -> get_lines(): $data is ""SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP ng13sm4536549pdb.21 - gsmtp"SERVER -> CLIENT: 220 smtp.gmail.com ESMTP ng13sm4536549pdb.21 - gsmtp
CLIENT -> SERVER: EHLO homeworth123.com
SMTP -> get_lines(): $data is ""SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [My IP shows here]"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]"SMTP -> get_lines(): $str is "250-SIZE 35882577"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577"SMTP -> get_lines(): $str is "250-8BITMIME"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577250-8BITMIME"SMTP -> get_lines(): $str is "250-STARTTLS"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577250-8BITMIME250-STARTTLS"SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES"SMTP -> get_lines(): $str is "250-PIPELINING"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING"SMTP -> get_lines(): $str is "250-CHUNKING"SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"SMTP -> get_lines(): $str is "250 SMTPUTF8"SERVER -> CLIENT: 250-smtp.gmail.com at your service, [My IP shows here]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SMTP -> get_lines(): $data is ""SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS"SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data is ""SMTP -> get_lines(): $str is ""SERVER -> CLIENT:
SMTP ERROR: QUIT command failed:
Connection: closed
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Ищете предложения по другим вещам, чтобы попробовать. Спасибо.

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]