wordpress中phpmail调用postfix/pmta smtp的问题

SMTP connect() failed

发送测试电子邮件时发生问题。

服务器证书配置错误。

这意味着服务器上的OpenSSL无法验证主机证书。

SMTP邮件服务


发送失败:SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

这个错误一般是因为你用postfix 引起的,测试过第三方smtp邮局是没有这个问题的,那个解决办法也很简单,

QQ:294959388  加我我告诉你怎么解决,100%搞定

<?php
/*
Plugin Name: WP SMTP PHP 5.6 fix
Version: 1.0
Author: unclego
Author URI: https://profiles.wordpress.org/unclego/
License: GPL2
Description: FIX for PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed when using PHP 5.6+ and mail server with self signed certificate
*/

/*
Installation

1. Create `wp-smpt-php-5.6-fix` into `WP_PLUGIN_DIR` ( `/wp-content/plugins/` on common WP instalation )
2. Copy this file (wp-smpt-php-5.6-fix.php) into new dir
3. Activate plugin

*/
#-------------------------------------------------------------------------------
class WP_SMTP_Customizer {
#-------------------------------------------------------------------------------
public static function _loader() {
add_action('phpmailer_init', array( get_class(), 'phpmailer_init'), 100 );
}
#-------------------------------------------------------------------------------
public static function phpmailer_init($phpmailer) {
// Bonus : Fixing The Return-Path Header
$phpmailer->Sender = $phpmailer->From;
// Fixing PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
WP_SMTP_Customizer::_loader();

原创文章,作者:ramuel,如若转载,请注明出处:https://www.ramuel.com/postfix/the-problem-of-phpmail-calling-postfix-pmta-smtp-in/

发表评论

登录后才能评论