【发布时间】: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