I am currently working on cygwin. I was trying to send and email through phpmailer using my gmail account and the following script (obtained online, then hacked):
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer(true);
try {
$mail->ISSMTP();
$mail->Host='smtp.gmail.com';
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->Port = 587;
$mail->Username = "myemail@gmail.com";
$mail->Password = "MyGooglePassword";
$mail->setFrom('myemail@gmail.com', 'my name1');
$mail->addAddress('anotheremail@email.fr', 'my name2');
$mail->Subject = 'PHPMailer Exceptions test';
$mail->Body = "Hi, This is the HTML BODY "; //HTML Body
$mail->AltBody = 'This is a plain-text message body';
$mail->send();
echo "Message sent!";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage();
}
I have seen multiple solutions on stack overflow, but I haven't found any telling how to properly self sign my localhost so that I would be able to avoid this error message:
PHP 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 /usr/share/pear/phpmailer/class.smtp.php on line 346
2015-11-30 08:47:15 SMTP Error: Could not connect to SMTP host.
2015-11-30 08:47:15 CLIENT -> SERVER: QUIT
2015-11-30 08:47:15 SMTP ERROR: QUIT command failed
I have also tried resolving the issues by setting 'verify_peer' to false at "$mail->SMTPOptions" (as recommended in: PHPMailer - SSL3_GET_SERVER_CERTIFICATE:certificate verify failed), but when I do that, my gmail account refuse to cooperate saying that the signing attempt does not meet modern security standard!!
Please let me know if there is a proper tutorial that would allow me to properly set my ssl and have the email successfuly sent with the proper verifications. Here is below a link to the gmail message: Gmail - sign in attempt prevented