Wordpress doesn't work properly with non standard domain names - PHPMailer fails when initialising

While debugging Wordpress password reset functionality in a test environment on a local macbook, Wordpress would get stuck when sending emails.

Basically, before sending emails, a check is done in wp-includes/pluggable.php on sender email address, subject, etc, and further debugging showed that Wordpress is failing on line 408 (in version 5.8.2)

$phpmailer-setFrom( $from_email, $from_name, false );

Ironically, this built-in check is performed before my custom action would correctly set the parameters:

add_action( 'phpmailer_init', 'my_phpmailer_example',5 );

function my_phpmailer_example( $phpmailer ) {
    $phpmailer-isSMTP();
    $phpmailer-Host = 'smtp.gmail.com';
    $phpmailer-SMTPAuth = true; // Force it to use Username and Password to authenticate
    $phpmailer-Port = 587;
    $phpmailer-Username = '[email protected]';
    $phpmailer-Password = 'thepassword';

    // Additional settings…
    $phpmailer-SMTPSecure = tls; // Choose SSL or TLS, if necessary for your server
    $phpmailer-From = [email protected];
    //$phpmailer-FromName = A mailer service;
}

The issue occurs because that the local test domain name is non standard, meaning it misses the TLD: http://mytestdomain

Why Wordpress is refusing to use nonstandard domains? Is it required to use local private domain names which include the Top Level Domain? Or some settings are wrong in my setup?

Topic smtp phpmailer wp-mail domain Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.