PHPMailer Error: SMTP & # 8594; ERROR: Failed to connect to server

I try google all morning, and I think I need Stackoverflow right now!

I wrote a simple script to send mail (from hotmail to gmail) but I get this error:

SMTP → ERROR: Could not connect to the server: the connection attempt failed because the connected party did not respond properly after some time or the connection was not established because the connected host could not respond. (10060) SMTP Connect () error. Mistake

This is the code:

<?php require_once("../includes/phpMailer/class.phpMailer.php"); require_once("../includes/phpMailer/class.smtp.php"); $to_name = "RECEIVER NAME"; $to = "RECEIVER@gmail.com"; $subject = "Mail test at " . strftime("%T", time()); $message = "This is a test message"; $message = wordwrap($message, 70); $from_name = "MY NAME"; $from = "MY_EMAIL@hotmail.it"; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 2; $mail->Host = "smtp.live.com"; $mail->Port = 25; $mail->SMTPAuth = true; $mail->Username = "MY USERNAME (hotmail)"; $mail->Password = "MY PASSWORD (hotmail)"; $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body = $message; $result = $mail->Send(); echo $result ? 'Sent' : 'Error'; ?> 

Other information is that the standard mail () function did not even work and did not check php info i:

sendmail_from - MY PROPER MAIL (hotmail)

sendmail_path - no value

SMTP - localhost

smtp_port - 25

Thank!

+5
php phpmailer smtp
Jul 16 '13 at 9:35 on
source share
3 answers

I believe port 25 is blocked on smtp.live.com. I also can not connect to smtp.live.com:25. Try using port 587 with TLS instead. So it will be:

 $mail->Port = 587; $mail->SMTPSecure = 'tls'; 
+4
Jul 16 '13 at 9:49 on
source share

I found a solution to this problem, try

Check if your PHP uses openSSL extension or not ...!

  • Edit php.ini from the installed php folder
  • Search extension = php_openssl.dll
  • The initial will look as follows :; extension = php_openssl.dll
  • Delete ';' and it will look like extension = php_openssl.dll
  • If you cannot find extension = php_openssl.dll , add this line extension = php_openssl.dll .
  • Then restart the Xampp or LAMP or APACHE server (depending on which one you are using).

Hope this method solves your problem ...

+2
Jan 11 '14 at
source share

You might want to check supported ports. For example, my host supports smtp through ports 25, 3535, and 80.
Using port 80 worked for me

0
Apr 14 '15 at 9:03
source share



All Articles