尝试通过 Gmail 服务器使用 PHPMail 时出错


Errors when trying to use PHPMail via the Gmail servers

我正在尝试为我的网站设置身份验证电子邮件。 我不需要任何花哨或安全的东西,但我在试图让它工作时遇到了很大的麻烦。

这是我的PHP

function emailconfirmation($temppass, $emailaddress) {
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 1;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 587;
    $mail->Username = 'myEmail@gmail.com';
    $mail->Password = 'myGmailPassword';
    $mail->SetFrom('myEmail@gmail.com');
    $mail->AddAddress($emailaddress);
    $mail->Subject = 'Test';
    $mail->Body    = 'test authentication key: ' . $temppass;
    if(!$mail->send()) {
        return 'Error: ' . $mail->ErrorInfo;
    } else {
        return true;
    }
}

这是它不断吐出的错误

2013-09-14 22:43:13 CLIENT -> SERVER: EHLO www.mydomain.com 2013-09-14 22:43:13 CLIENT -> SERVER: STARTTLS
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in C:'wamp'bin'php'includes'PHPMailer-master'class.smtp.php on line 274
2013-09-14 22:43:13 CLIENT -> SERVER: QUIT 2013-09-14 22:43:13  SMTP ERROR: QUIT command failed: SMTP connect() failed.

你们可以提供的任何帮助都会很棒。 仅供参考,我已经允许端口 587 通过我的防火墙,我发送到的电子邮件与我发送的电子邮件不同。 谢谢!


编辑:说真的,没人吗? 这真的让我很紧张

您需要在WAMP设置中启用OpenSSL。

我看到您取消注释了这一行:extension=php_openssl.dll这很好,但显然带有 apache 2.4.4 的 Wampserver 发布了错误的 OpenSSL 文件!

根据这个其他StackOverflow响应,您应该自己下载安装Win32 OpenSSL文件。

然后停止WAMP,从新安装的OpenSSL目录中获取这些文件:

bin'openssl.cfg
bin'libeay32.dll
bin'ssleay32.dll
bin'openssl.exe

将它们复制到 WAMP/Apache 目录中的这些文件上:

conf'openssl.cnf (rename the openssl.cfg file to openssl.cnf to overwrite this)
bin'libeay32.dll
bin'ssleay32.dll
bin'openssl.exe

最后,启动 WAMP。