电子邮件标题阻止链接?

时间:2017-10-10 04:51:55

标签: php wordpress

我有这个标题:

$headers = array( 'Content-Type: text/html; charset=UTF-8' );

这种消息:

$redirectUrl=network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
$message .= '<a href="'.$redirecturl.'">'.$redirectUrl.'</a>';

如果我在localhost中打印此消息,它会显示链接,一切都很好。 但。当我通过电子邮件发送此消息时,该链接未显示在电子邮件中。

wp_mail( $user_data->user_email, $subject, $message, $headers);

如果我不再使用$headers所有好处。我做错了什么?

1 个答案:

答案 0 :(得分:0)

作为https://developer.wordpress.org/reference/functions/wp_mail/

的摘录
  

默认内容类型为“text / plain”,不允许使用HTML。但是,您可以使用“wp_mail_content_type”过滤器设置电子邮件的内容类型。

在这种情况下,请尝试将此添加到您的functions.php

function set_content_type(){
    return "text/html";
}
add_filter( 'wp_mail_content_type','set_content_type' );
相关问题