WP Mail SMTP 版本 1.4.2 停止发送电子邮件
WP Mail SMTP Version 1.4.2 stopped sending emails
我有一个插件,它使用 wp_mail()
函数在表单错误时发送电子邮件。我还安装了 WP Mail SMTP 插件以使用我的自定义 SMTP 设置。
使用 WP Mail SMTP 版本 0.11.1 几个月来一切都很好。但是自从我将插件更新到1.4.2版本后,我的电子邮件就停止工作了。
据我了解,wp_mail()
仅在我的插件中不起作用。如果我将它保存在主题文件等任何地方,电子邮件将立即发送。但是从我的插件内部,我每次都会得到这个异常:
"errors": {
"wp_mail_failed": [
"Could not instantiate mail function."
]
},
"error_data": {
"wp_mail_failed": {
"to": [
"oibrahim@folio3.com"
],
"subject": "Form Error",
"message": "<dl><dt>Error Logged:<\/dt> <dd>{\"MembershipNumber\":null,\"Success\":false,\"Message\":\"The combination is incorrect\",\"contactInfo\":{\"PrimaryContactNumber\":null,\"AlternateNumber\":null,\"MobileNumber\":null,\"OtherPhone1\":null,\"Email\":null},\"membership\":{\"EffectiveDate\":null,\"ExpiryDate\":null,\"planInfo\":null,\"MembershipSubProgram\":null},\"address\":{\"HomeAddress\":null,\"MailingAddress\":null,\"BillingAddress\":null},\"slxConstantInfo\":[],\"Token\":null}<\/dd><dt>Timestamp:<\/dt> <dd>Monday, April 22nd, 2019 @ 03:16:30 PM<\/dd><dt>Referrer:<\/dt> <dd>renew\/step1<\/dd><dt>User:<\/dt> <dd> \n<br>\n<br>\n<br>\n<\/dd><\/dl>",
"headers": [
],
"attachments": [
],
"phpmailer_exception_code": 2
}
}
}
如果我降级 WP Mail SMTP 插件,一切都会重新开始正常工作。所以它肯定是插件的问题。也许在我调用 wp_mail()
函数的插件中,WP Mail SMTP 的设置尚未加载或类似内容。
任何快速帮助将不胜感激,因为我在生产站点上有此代码 运行。提前致谢!
编辑:只是为了添加一些细节,WP Mail SMTP 测试电子邮件 运行 没问题!
could not instantiate mail function
错误意味着您没有安装本地邮件服务器,但只有在您使用 mail()
时才会出现这种情况 – 如果您使用 SMTP,则不会出现这种情况.所以听起来你的怀疑是正确的——wp_mail 的配置由于某种原因没有加载,或者 SMTP 插件没有做它应该做的事情。
没关系。我在 WP MAIL SMTP 支持论坛上发帖但没有得到回应。我发现 phpmailer
对象没有在我的插件中保存修改后的设置。所以这是我实施的解决方法,只是为了让事情正常进行,尽管我知道这不是最好的解决方法。
我在插件的初始化中放置了以下操作:
/**
* Reconfigure SMTP setting to make WP MAIL SMTP plugin work
*/
add_action( 'phpmailer_init', 'reconfigure_smtp' );
function reconfigure_smtp( $phpmailer ) {
$SMTPhost = get_option('smtp_host');
$SMTPport = get_option('smtp_port');
$FromEmail = get_option('mail_from');
$FromName = get_option('mail_from_name');
$phpmailer->isSMTP();
$phpmailer->Host =$SMTPhost;
$phpmailer->Port = $SMTPport;
$phpmailer->From = $FromEmail;
$phpmailer->FromName = $FromName;
}
这只是获取 WP MAIL SMTP 存储的选项,然后重新配置 phpmailer 实例。这只是迫切需要尽快解决问题的结果。
我有一个插件,它使用 wp_mail()
函数在表单错误时发送电子邮件。我还安装了 WP Mail SMTP 插件以使用我的自定义 SMTP 设置。
使用 WP Mail SMTP 版本 0.11.1 几个月来一切都很好。但是自从我将插件更新到1.4.2版本后,我的电子邮件就停止工作了。
据我了解,wp_mail()
仅在我的插件中不起作用。如果我将它保存在主题文件等任何地方,电子邮件将立即发送。但是从我的插件内部,我每次都会得到这个异常:
"errors": {
"wp_mail_failed": [
"Could not instantiate mail function."
]
},
"error_data": {
"wp_mail_failed": {
"to": [
"oibrahim@folio3.com"
],
"subject": "Form Error",
"message": "<dl><dt>Error Logged:<\/dt> <dd>{\"MembershipNumber\":null,\"Success\":false,\"Message\":\"The combination is incorrect\",\"contactInfo\":{\"PrimaryContactNumber\":null,\"AlternateNumber\":null,\"MobileNumber\":null,\"OtherPhone1\":null,\"Email\":null},\"membership\":{\"EffectiveDate\":null,\"ExpiryDate\":null,\"planInfo\":null,\"MembershipSubProgram\":null},\"address\":{\"HomeAddress\":null,\"MailingAddress\":null,\"BillingAddress\":null},\"slxConstantInfo\":[],\"Token\":null}<\/dd><dt>Timestamp:<\/dt> <dd>Monday, April 22nd, 2019 @ 03:16:30 PM<\/dd><dt>Referrer:<\/dt> <dd>renew\/step1<\/dd><dt>User:<\/dt> <dd> \n<br>\n<br>\n<br>\n<\/dd><\/dl>",
"headers": [
],
"attachments": [
],
"phpmailer_exception_code": 2
}
}
}
如果我降级 WP Mail SMTP 插件,一切都会重新开始正常工作。所以它肯定是插件的问题。也许在我调用 wp_mail()
函数的插件中,WP Mail SMTP 的设置尚未加载或类似内容。
任何快速帮助将不胜感激,因为我在生产站点上有此代码 运行。提前致谢!
编辑:只是为了添加一些细节,WP Mail SMTP 测试电子邮件 运行 没问题!
could not instantiate mail function
错误意味着您没有安装本地邮件服务器,但只有在您使用 mail()
时才会出现这种情况 – 如果您使用 SMTP,则不会出现这种情况.所以听起来你的怀疑是正确的——wp_mail 的配置由于某种原因没有加载,或者 SMTP 插件没有做它应该做的事情。
没关系。我在 WP MAIL SMTP 支持论坛上发帖但没有得到回应。我发现 phpmailer
对象没有在我的插件中保存修改后的设置。所以这是我实施的解决方法,只是为了让事情正常进行,尽管我知道这不是最好的解决方法。
我在插件的初始化中放置了以下操作:
/**
* Reconfigure SMTP setting to make WP MAIL SMTP plugin work
*/
add_action( 'phpmailer_init', 'reconfigure_smtp' );
function reconfigure_smtp( $phpmailer ) {
$SMTPhost = get_option('smtp_host');
$SMTPport = get_option('smtp_port');
$FromEmail = get_option('mail_from');
$FromName = get_option('mail_from_name');
$phpmailer->isSMTP();
$phpmailer->Host =$SMTPhost;
$phpmailer->Port = $SMTPport;
$phpmailer->From = $FromEmail;
$phpmailer->FromName = $FromName;
}
这只是获取 WP MAIL SMTP 存储的选项,然后重新配置 phpmailer 实例。这只是迫切需要尽快解决问题的结果。