Change lost password url to a mailto URL in WordPress

This answer assumes you’re running PHP 5.3 or above.

Use the filter code below in-place of your code that you quoted above. Then simply update the variables provided so that it’s sending to the correct email address and with the particular subject you’d like.

add_filter( 'lostpassword_url', function () {
    $email_to = '[email protected]';
    $email_subject="Help I lost my password";
    return sprintf( 'mailto:%s?subject=%s', $email_to, $email_subject );
}, 100, 0 );

Note: You cannot change the anchor text “Lost Password” that is used in the link.