我目前正在研究cygwin。 我试图通过phpmailer使用我的Gmail帐户和以下脚本(在线获取,然后入侵)发送和发送电子邮件:
<?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();
}
我已经看到堆栈溢出的多个解决方案,但我还没有找到任何告诉如何正确地自我签署我的localhost,以便我能够避免此错误消息:
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
我也尝试通过在“$ mail-&gt; SMTPOptions”(在PHPMailer - SSL3_GET_SERVER_CERTIFICATE:certificate verify failed中推荐)将'verify_peer'设置为false来解决问题,但是当我这样做时,我的gmail帐户拒绝合作说签约尝试不符合现代安全标准!!
如果有正确的教程可以让我正确设置我的ssl并通过适当的验证成功发送电子邮件,请告诉我。 以下是gmail消息的链接:Gmail - sign in attempt prevented