phpmailer傳送郵件出現錯誤:stream_socket_enable_crypto():SSLoperationfailedwithcode1.
如果開了除錯,除錯進去會看到錯誤提示:
- smtp_code:“stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed”
最終提示是:Could not connect to SMTP host
原因是升到php5.6後預設開啟驗證
新增引數,去掉驗證:
- $mail->SMTPOptions = array(
- `ssl` => array(
- `verify_peer` => false,
- `verify_peer_name` => false,
- `allow_self_signed` => true,
- )
- )
參考文件:
http://php.net/manual/en/context.ssl.php
去掉驗證:
I am unable to load a PEM that was generated with the stunnel tools. However, I am able to use PHP calls to generate a working PEM that is recognized both by stunnel and php, as outlined here:
http://www.devdungeon.com/content/how-use-ssl-sockets-php
This code fragment is now working for me, and with stunnel verify=4, both sides confirm the fingerprint. Oddly, if “tls://” is set below, then TLSv1 is forced, but using “ssl://” allows TLSv1.2:
$stream_context = stream_context_create([ `ssl` => [
`local_cert` => `/path/to/key.pem`,
`peer_fingerprint` => openssl_x509_fingerprint(file_get_contents(`/path/to/key.crt`)),
`verify_peer` => false,
`verify_peer_name` => false,
`allow_self_signed` => true,
`verify_depth` => 0 ]]);
$fp = stream_socket_client(`ssl://ssl.server.com:12345`,
$errno, $errstr, 30, STREAM_CLIENT_CONNECT, $stream_context);
fwrite($fp, “foo bar
“);
while($line = fgets($fp, 8192)) echo $line;
http://php.net/manual/en/context.ssl.php
如何聯絡我:【萬里虎】www.bravetiger.cn
【QQ】3396726884 (諮詢問題100元起,幫助解決問題500元起)
【部落格】http://www.cnblogs.com/kenshinobiy/
相關文章
- 使用phpmailer傳送郵件PHPAI
- ThinkPHP6結合PHPMailer傳送郵件PHPAI
- 用phpmailer實現網頁表單提交傳送郵件功能PHPAI網頁
- 專案部署時郵件傳送錯誤
- Laravel 傳送郵件報錯Laravel
- SpringBoot整合Mail傳送郵件&傳送模板郵件Spring BootAI
- python實現傳送郵件Python
- 郵件傳送
- 傳送郵件
- Laravel5.8 傳送郵件報錯Laravel
- python實現郵件的傳送Python
- oracle 傳送郵件 實現方法Oracle
- java郵件傳送Java
- python傳送郵件Python
- Django——郵件傳送Django
- gmail傳送郵件AI
- phpcms傳送郵件PHP
- 郵件的傳送
- Laravel 傳送郵件Laravel
- thinkjs 傳送郵件JS
- SpringBoot傳送郵件Spring Boot
- SpringBoot郵件傳送Spring Boot
- Laravel傳送郵件Laravel
- PHP傳送郵件PHP
- nodejs 傳送郵件NodeJS
- Spring Boot實現傳送QQ郵件Spring Boot
- SpringBoot實現傳送電子郵件Spring Boot
- java 如何實現傳送郵件 email?JavaAI
- Springboot+Javamail實現郵件傳送Spring BootJavaAI
- Java Mail 郵件傳送(二):簡單封裝的郵件傳送JavaAI封裝
- golang傳送郵件(qq郵箱)Golang
- Android 快速傳送郵件Android
- SpringBoot傳送郵件(二)Spring Boot
- SpringBoot傳送郵件(三)Spring Boot
- 定時傳送郵件
- 使用 smtplib 傳送郵件
- Python SMTP傳送郵件Python
- 郵件傳送API整理API
- php windows 傳送郵件PHPWindows