WP Mail SMTP版本1.4.2停止发送电子邮件

问题描述 投票:1回答:2

我有一个插件,使用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": [
        "[email protected]"
      ],
      "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测试邮件正常运行!

php wordpress smtp phpmailer
2个回答
0
投票

could not instantiate mail function错误意味着您没有安装本地邮件服务器,但只有在您使用mail()时才会发生 - 如果您使用的是SMTP,它将不适用。所以听起来你的怀疑是正确的 - wp_mail的配置由于某种原因尚未加载,或者SMTP插件没有按照预期进行操作。


0
投票

没关系。我在WP MAIL SMTP支持论坛上发布但没有得到回应。我发现phpmailer对象没有在我的插件中保存修改后的设置。所以这是我为实现工作而实施的解决方法,尽管我知道这不是最好的解决方案。

我在我的插件的init中放置了以下操作:

/**
 *  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实例。这只是迫切需要尽快解决问题的结果。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.