SMTP电子邮件无法在Xampp本地托管的wordpress网站上运行

时间:2017-11-14 11:26:56

标签: php xampp smtp contact-form-7

我在xampp本地工作,并使用Gmail SMTP plugin让我的联系表单7正常工作。当我尝试发送测试电子邮件时,它失败了,我收到此错误消息:

Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:\xampp1\htdocs\WP\wp-content\plugins\gmail-smtp\PHPMailer\class.smtp.php line 369]
SMTP Error: Could not connect to SMTP host.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我相应更改了php.inisendmail配置中的邮件功能设置。你能帮我解决一下这个问题吗?

2 个答案:

答案 0 :(得分:1)

您最有可能得到此错误,因为在内部,PHPMailer正在尝试建立安全连接(SSL / HTTPS)并且SSL证书验证失败,因为它最像self-signed certificate(仅用于开发的xampp内部) )。

尝试使用建议的代码片段,允许不安全的连接(不使用SSL加密 - 至少在开发期间)

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

由于文档本身建议不要在php.ini文件中全局进行这些配置,因此您可能希望还原它们。并使用运行时选项(上面的代码)。

答案 1 :(得分:0)

这是我的smtp客户端,用于从php发送带有ssl socket https://github.com/breakermind/PhpMimeParser/blob/master/PhpSmtpSslSocketClient.php的电子邮件,你可以用php测试 这里有php邮件示例https://github.com/fxstar/PhpJsCss/blob/master/SMTPmail/send-phpmailer-smtp-ssl.php 或者这里是另一个例子https://github.com/fxstar/PhpJsCss/blob/master/MailerPHP/smtp.php

相关问题