log_mail_errors does not work in wordpress.com environment
-
On wordpress.com there is a probplem with the e-mail log in the following function:
function log_mailer_errors( $mailer ) { if ( $mailer ) { $fn = ABSPATH . '/wp-content/mail.log'; // say you've got a mail.log file in your server root /* phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen */ $fp = fopen( $fn, 'a' ); /* phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fputs */ fputs( $fp, "Mailer Error: " . print_r( $mailer, true ) . "\n" ); /* phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose */ fclose( $fp ); } }
The problem is, that on wordpress.com ABSPATH is not writeable, because the wordpress folder is mounted in! So this will then obviously fail, and provide the beloved wordpress errormessage.
It should be an easy fix to just put the mail.log to a different folder.
Here is the stack trace
[15-Apr-2024 03:00:08 UTC] PHP Warning: fopen(/wordpress/core/6.5.2//wp-content/mail.log): Failed to open stream: Read-only file system in /srv/htdocs/wp-content/plugins/classified-listing/app/Controllers/Admin/EmailSettings.php on line 17
[15-Apr-2024 03:00:08 UTC] PHP Fatal error: Uncaught TypeError: fputs(): Argument #1 ($stream) must be of type resource, bool given in /srv/htdocs/wp-content/plugins/classified-listing/app/Controllers/Admin/EmailSettings.php:19
Stack trace: 0 /srv/htdocs/wp-content/plugins/classified-listing/app/Controllers/Admin/EmailSettings.php(19): fputs(false, ‘Mailer Error: W…’) 1 /wordpress/core/6.5.2/wp-includes/class-wp-hook.php(324): Rtcl\Controllers\Admin\EmailSettings->log_mailer_errors(Object(WP_Error)) 2 /wordpress/core/6.5.2/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(”, Array) 3 /wordpress/core/6.5.2/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 4 /wordpress/core/6.5.2/wp-includes/pluggable.php(581): do_action(‘wp_mail_failed’, Object(WP_Error)) 5 [internal function]: wp_mail(Array, ‘[WE-NET ] Veri…’, ‘…’, Array, Array) 6 /srv/htdocs/wp-content/plugins/classified-listing/app/Models/RtclEmail.php(763): call_user_func_array(‘wp_mail’, Array) 7 /srv/htdocs/wp-content/plugins/classified-listing-pro/app/Emails/UserVerifyLinkEmailToUser.php(68): Rtcl\Models\RtclEmail->send() 8 /srv/htdocs/wp-content/plugins/classified-listing-pro/app/Models/UserAuthentication.php(47): RtclPro\Emails\UserVerifyLinkEmailToUser->trigger(Object(WP_User), ’59c6a17f01ca48f…’) 9 /srv/htdocs/wp-content/plugins/classified-listing-pro/app/Models/UserAuthentication.php(26): RtclPro\Models\UserAuthentication::send_email(Object(WP_User)) 10 /srv/htdocs/wp-content/plugins/classified-listing-pro/app/Controllers/AuthController.php(114): RtclPro\Models\UserAuthentication::send_verification_link(110) 11 /wordpress/core/6.5.2/wp-includes/class-wp-hook.php(326): RtclPro\Controllers\AuthController::user_register(110) 12 /wordpress/core/6.5.2/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) 13 /wordpress/core/6.5.2/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 14 /wordpress/core/6.5.2/wp-includes/user.php(2508): do_action(‘user_register’, 110, Array) 15 /srv/htdocs/wp-content/plugins/classified-listing/app/Helpers/Functions.php(3563): wp_insert_user(Array) 16 /srv/htdocs/wp-content/plugins/classified-listing/app/Controllers/FormHandler.php(304): Rtcl\Helpers\Functions::create_new_user(‘tester2@wundern…’, ‘tester2’, ‘tester’, Array) 17 /wordpress/core/6.5.2/wp-includes/class-wp-hook.php(324): Rtcl\Controllers\FormHandler::process_registration(”) 18 /wordpress/core/6.5.2/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) 19 /wordpress/core/6.5.2/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 20 /wordpress/core/6.5.2/wp-settings.php(717): do_action(‘wp_loaded’) 21 /srv/htdocs/wp-config.php(100): require_once(‘/wordpress/core…’) 22 /wordpress/core/6.5.2/wp-load.php(55): require_once(‘/srv/htdocs/wp-…’) 23 /wordpress/core/6.5.2/wp-blog-header.php(13): require_once(‘/wordpress/core…’) 24 /wordpress/core/6.5.2/index.php(17): require(‘/wordpress/core…’) 25 {main}thrown in /srv/htdocs/wp-content/plugins/classified-listing/app/Controllers/Admin/EmailSettings.php on line 19
- The topic ‘log_mail_errors does not work in wordpress.com environment’ is closed to new replies.