cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
suhasz
New

SMTP connect() failed. Can't send email from local. PHP 7.1 + PHPMailer

Hello,

 

I am trying to send an email from the local PHP script specified below. But I keep getting the error:

 

2021-01-10 17:02:50 SMTP ERROR: Failed to connect to server: Operation timed out (60)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting.

 

Here is my code:

 

<?php

use PHPMailer\PHPMailer\PHPMailer;

use PHPMailer\PHPMailer\SMTP;

use PHPMailer\PHPMailer\Exception;

 

require_once __DIR__ . '/vendor/phpmailer/src/Exception.php';

require_once __DIR__ . '/vendor/phpmailer/src/PHPMailer.php';

require_once __DIR__ . '/vendor/phpmailer/src/SMTP.php';

 

$mail = new PHPMailer();

$mail->IsSMTP();

 

$mail->Host       = "relay-hosting.secureserver.net";

$mail->Port       = 25;

$mail->SMTPDebug  = SMTP::DEBUG_SERVER;

$mail->SMTPSecure = "none";

$mail->SMTPAuth   = true;

$mail->Username   = 'sender@myhost.com';

$mail->Password   = '********';

 

$mail->SetFrom('sender@myhost.com','Sender');

$mail->AddReplyTo('sender@myhost.com','Sender');

$mail->Subject = "Welcome to Email";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";

$mail->MsgHTML('This is a test.');

$mail->AddAddress('receiver@gmail.com', 'Receiver');

try {

   $mail->Send();

} catch (Exception $e) {

   echo "Error in sending email. Mailer Error: {$mail->ErrorInfo}";

}

 

Any help is appreciated.

 

Thanks!

0 REPLIES 0