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";

The email I got link without wp-login.php

Someone requested that the password be reset for the following account:

http://localhost.com/

Username: test12

If this was a mistake, just ignore this email and nothing will happen.

To reset your password, visit the following address:

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

I debugged and found that system is checking if link having wp-login.php then remove this file name from link and send mail. Is there any file in which we can check?

Answers


I had the same problem. For me the solution was to parse mail as html. I added this into functions and it works now.

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;
}

First function changes header of all emails to text/html. Second function changes the \r\n line breaks for <br /> ones.


Need Your Help

Preprocessor counter macro

c++ macros c-preprocessor counter

Is there a way to create a COUNTER() macro (which follows the C++11/14 standard) that is expanded to a number which increases by one every time COUNTER() is invoked?