Reputation: 589
I am using PHPMailer class to send an email from my website, locally its work good but on my online server I got an error:
2018-05-28 12:03:40 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()
2018-05-28 12:03:40 Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [/home/beesystems/public_html/specs/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2018-05-28 12:03:40 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [/home/beesystems/public_html/specs/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2018-05-28 12:03:40 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [/home/beesystems/public_html/specs/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2018-05-28 12:03:40 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
code:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = \Yii::$app->params['mailer-account'];
$mail->Password = \Yii::$app->params['mailer-password'];
Upvotes: 0
Views: 3167
Reputation: 37710
This is the important part:
SSL routines:ssl3_get_server_certificate:certificate verify failed
This is covered extensively in the troubleshooting guide the error message links to, and has been answered many times on here. Switching SMTPSecure
to tls
on port 587 won't help. It's most likely that your server is running an old version of PHP, or has an outdated CA certificates bundle.
Upvotes: 0