The same script with the same settings on Windows works, not on Linux.

<?php include 'PHPMailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->isSMTP(); $mail->Host = 'smtp.mail.ru'; $mail->SMTPAuth = true; $mail->Username = 'mailfrom@mailru'; $mail->Password = 'password'; //пароль $mail->SMTPSecure = 'ssl'; $mail->Port = 465; $mail->CharSet = 'UTF-8'; $mail->From = 'mailfrom@mailru'; // из какого эмейла $mail->FromName ='куда'; $mail->addAddress("mailto@mail.ru"); $mail->isHTML(true); $mail->Subject = "sssssssss"; $mail->Body = "gggggg"; $mail->AltBody = 'это альтернативное письмо'; $mail->SMTPDebug =3; if($mail->send()){ //echo 'письмо отправлено! Для окончания активации, зайдите на свой email и перейдите по ссылке в письме для окончания активации'; }else{ echo 'ошибка:' . $mail->ErrorInfo; } ?> 

phpmailer Version: 5.2.8

php version: 5.6.8

error that happens on linux

2015-07-23 09:26:51 Connection: opening 2015-07-23 09:26:52 SMTP ERROR: Failed to connect to server: (0) SMTP connect () failed. Error: SMTP connect () failed.

  • Apparently, on Linux you need to open the 25th port out. - Vesper
  • it is necessary in the settings of the OSes itself to do? - Yuri
  • Yeah, only I don’t know how to manage a firewall on Linux yet. - Vesper
  • @Yuri, if the Internet is generally available on this machine, it means that on the way to the smtp.mail.ru server, connections to port 465 are blocked. To find out if your machine is to blame, or someone further down the chain, see for yourself or attach To the question the output command with superuser privileges: iptables-save . it will show the entire netfilter configuration (this is the linux program subsystem that handles the processing of network packets). - aleksandr barakin
  • smtp.mail.ru , at the same time it would be nice to check if other ports that are open on the smtp.mail.ru server are smtp.mail.ru : 25, 587 or 2525. This can be done, for example, using the telnet program: telnet сервер порт . if only one line trying ip-адрес... type the trying ip-адрес... and will “hang”, it means the connection does not occur. You can interrupt waiting with ctrl+c . if the program displays several lines, and among them is connected to сервер , the connection has occurred. in this case, you can interrupt like this: ctrl+] , then enter enter the word quit and enter again. - aleksandr barakin

1 answer 1

if the Internet is generally available on this machine, it means that on the way to the smtp.mail.ru server, connections to port 465 are blocked.

to find out if your machine is guilty, or someone further down the chain, look for yourself or attach the output of the command, executed with superuser privileges:

 $ iptables-save 

it will show the entire configuration of netfilter (it is the linux program subsystem that deals with the processing of network packets).


at the same time it would be nice to check if the other ports that are open at the smtp.mail.ru server smtp.mail.ru : 25, 587 or 2525.

This can be done, for example, with the telnet program:

 $ telnet сервер порт 

if only one line trying ip-адрес... type the trying ip-адрес... and will “hang”, it means the connection does not occur. You can interrupt waiting with ctrl + c .

if the program displays several lines, and among them is connected to сервер , the connection has occurred. in this case, you can interrupt like this: ctrl +] , then enter enter the word quit and enter again.