network_site_url() from wp-login page WordPress not working

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

The email I got link without wp-login.php

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

Read More

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?

Related posts

Leave a Reply

1 comment

  1. 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("rn", "<br />", $mail['message']);
        return $mail;
    }
    

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