I would send email with SMTP in PHP. I use Gmail SMTP.
My code :
<?php
require 'PHPMailer_5.2.0/class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'egenthiers.80@gmail.com'; // SMTP username
$mail->Password = 'XXXX'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'egenthiers.80@gmail.com';
$mail->FromName = 'Egen Can';
$mail->AddAddress('egenthiers.63@gmail.com', 'Egen Can'); // Add a recipient
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
?>
When I run this code. I get this error :
Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\xampp\htdocs\xxx\PHPMailer_5.2.0\class.smtp.php on line 200 Language string failed to load: tls Message could not be sent.Mailer Error: Language string failed to load: tls SMTP server error:
How can I solve this problem?
I need your help.