I operate some servers which have a few WordPress websites on them. I was having some issues with the cron jobs being triggered too often or not enough so I replaced all of them with crontab entries, one or more for each site as appropriate.
Most documentation I have seen uses
wget and dumps the output to
/dev/null so I wanted to use PHP directly since it is a PHP file after all and I would then capture any error output that way.
This accomplishes the tasks I want to fine however now every few weeks I get several of the following messages:
PHP Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: (setFrom) wordpress@' in /path/to/website/public_html/wp-includes/class-phpmailer.php:1023 Stack trace: #0 /path/to/website/public_html/wp-includes/pluggable.php(352): PHPMailer->setFrom('wordpress@', 'WordPress', false) #1 /path/to/website/public_html/wp-admin/includes/class-wp-automatic-updater.php(769): wp_mail('<adminemail>', '<subject>', '<message>', '') #2 /path/to/website/public_html/wp-admin/includes/class-wp-automatic-updater.php(501): WP_Automatic_Updater->send_email('success', Object(stdClass)) #3 /path/to/website/public_html/wp-admin/includes/class-wp-automatic-updater.php(470): WP_Automatic_Updater->after_core_update(Object(stdClass)) #4 /path/to/website/public_html/wp-includes/update.php(532): WP_Automatic_Updater->run() #5 [internal function]: wp_maybe_auto_update( in /path/to/website/public_html/wp-includes/class-phpmailer.php on line 1023
As I understand it,
wp-cron.php has successfully caused the WordPress to be updated to the next version and wanted to email the site administrator about it.
Examining the code of
wp-includes/pluggable.php I can see that it tries to generate a "from email address" using the contents of
$_SERVER which obviously aren't there as it is being run from the command line and not via the web server.
I feel that using PHP directly from the command line is more efficient than invoking
wget but also there is no error checking present to verify a "from email address" has been generated correctly.
My question is, which of the following is true (or are both?) and what should I do about it:
wp-cron.php should ONLY be called using
curl and there is error checking missing that would force the administrator to avoid cli
wp-includes/pluggable.php is missing email validation checking
I can see there has been hefty debate about how an email address should be generated but am keen to not dig up resolved arguments and would appreciate a direction in resolving this issue.