network_site_url() from wp-login page WordPress not working


network_site_url() from wp-login page WordPress not working

$message = __('Someone requested that the password be reset for the following account:') . "'r'n'r'n";
$message .= network_home_url( '/' ) . "'r'n'r'n";
$message .= sprintf(__('Username: %s'), $user_login) . "'r'n'r'n";
$message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "'r'n'r'n";
$message .= __('To reset your password, visit the following address:') . "'r'n'r'n";
$message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">'r'n";

我收到的邮件链接没有wp-login.php

有人要求为以下内容重置密码账户:

http://localhost.com/

用户名:test12

如果这是一个错误,就忽略这封邮件,什么也不会发生。

要重置密码,请访问以下地址:

<http://localhost.com?action=rp&key=$P$Btka6BPNxTtMA2ohCF4bLMwaQ0pXHc/&login=test12>

我调试了,发现系统正在检查链接是否有wp-login.php,然后从链接中删除这个文件名并发送邮件。有什么文件可以查吗?

我也遇到了同样的问题。对我来说,解决方案是将邮件解析为html。我将它添加到函数中,现在它可以工作了。

function html_laiskai(){
    return "text/html";
}
add_filter( 'wp_mail_content_type','html_laiskai' );
add_filter( 'wp_mail', 'html_email_encode_body' );
function html_email_encode_body( $mail ) {
    $mail['message'] = str_replace("'r'n", "<br />", $mail['message']);
    return $mail;
}

第一个函数将所有邮件的标题更改为text/html。第二个函数将'r'n换行符更改为<br />换行符。