PHPmailer: Smtp Error: Could Not Connect to Smtp Host

How to resolve 'SMTP Error: Could not connect to SMTP host.' in phpmailer?

First of all, while initiating PHPMailer send in the parameter true like,

$mailer = new PHPMailer(true);

This will help you to catch and handle exceptions.

Secondly, try this

$mailer->SMTPSecure = 'ssl'; // instead of tls

PHPMailer: Could not connect to SMTP host

$mailer->Host = 'ssl://smtp.gmail.com:465';

PHPMailer + smtp.gmail.com : Could not connect to SMTP host

Just Add the following codes before line code $mail->SMTPDebug saves the day

$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);


Related Topics



Leave a reply



Submit