【问题标题】:Wordpress wp_mail() returns falseWordpress wp_mail() 返回 false
【发布时间】:2022-01-22 17:29:51
【问题描述】:

我是插件开发的新手。我想在 Wordpress 中使用这个简单的功能向用户发送邮件。我在文档中看到了这段代码,一切都很简单直接,但是这段代码返回 false。为什么?

require_once explode( 'wp-content', __FILE__ )[0] . 'wp-load.php';
function send_mail() {
    $to      = 't.testmail@gmail.com';
    $subject = 'The subject';
    $body    = 'The email body content';
    $headers = array( 'Content-Type: text/html; charset=UTF-8' );

    $send_message = wp_mail( $to, $subject, $body, $headers );

    if ( $send_message ) {
        echo 'Email was sent';
    } else {
        echo 'Email sending was aborted';
    }
}

send_mail();

【问题讨论】:

    标签: wordpress function wp-mail


    【解决方案1】:

    根据文档 (https://developer.wordpress.org/reference/functions/wp_mail/) 无法发送邮件。 原因可能很多。有没有查看 WordPress 的调试日志(https://wordpress.org/support/article/debugging-in-wordpress/)?

    【讨论】:

      猜你喜欢
      • 2015-07-06
      • 2014-10-21
      • 2017-01-31
      • 2021-04-29
      • 2020-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多