Jagajaga
Новичок
Здравствуйте. Пытаюсь отправить почту с mail.ru. Но никак не получается. Пробовал средствами Laravel:
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.mail.ru
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=SSL
Mail::queue('emails.a', [], function ($message) {
dd($message->to('[email protected]')->from('[email protected]')->subject('Письмо'));
});
Пробовал через PHPMailer
$mail = new \PHPMailer();
$mail->SMTPDebug = 3;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.ru'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'username'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = '465';
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Получаю:
2016-07-30 16:01:02 Connection: opening to ssl://smtp.mail.ru:465, timeout=300, options=array ( )
2016-07-30 16:03:08 SMTP ERROR: Failed to connect to server: Network is unreachable (101)
2016-07-30 16:03:08 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Ничего не получается. Хотя с gmail.com все отправляется нормально. Данная проблема возникла после введения новой защиты от спама. Что я делаю не так?
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.mail.ru
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=SSL
Mail::queue('emails.a', [], function ($message) {
dd($message->to('[email protected]')->from('[email protected]')->subject('Письмо'));
});
Пробовал через PHPMailer
$mail = new \PHPMailer();
$mail->SMTPDebug = 3;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.ru'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'username'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = '465';
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Получаю:
2016-07-30 16:01:02 Connection: opening to ssl://smtp.mail.ru:465, timeout=300, options=array ( )
2016-07-30 16:03:08 SMTP ERROR: Failed to connect to server: Network is unreachable (101)
2016-07-30 16:03:08 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Ничего не получается. Хотя с gmail.com все отправляется нормально. Данная проблема возникла после введения новой защиты от спама. Что я делаю не так?