Opened 2 years ago
Closed 2 years ago
#57241 closed defect (bug) (wontfix)
PHP 8.x and PHPMailer error
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.1.1 |
Component: | Keywords: | ||
Focuses: | Cc: |
Description
When mail() function is disabled, during a new WordPress 6.1.1 installation but also when I try to add a new user I get this error:
Fatal error: Uncaught Error: Call to undefined function PHPMailer\PHPMailer\mail() in /home/www/user/example.net/www/wp-includes/PHPMailer/PHPMailer.php:874 Stack trace: #0 /home/www/user/example.net/www/wp-includes/PHPMailer/PHPMailer.php(1945): PHPMailer\PHPMailer\PHPMailer->mailPassthru('chris@cretaforc...', '[test] New User...', 'New user regist...', 'Date: Thu, 1 De...', NULL) #1 /home/www/user/example.net/www/wp-includes/PHPMailer/PHPMailer.php(1666): PHPMailer\PHPMailer\PHPMailer->mailSend('Date: Thu, 1 De...', 'New user regist...') #2 /home/www/user/example.net/www/wp-includes/PHPMailer/PHPMailer.php(1502): PHPMailer\PHPMailer\PHPMailer->postSend() #3 /home/www/user/example.net/www/wp-includes/pluggable.php(542): PHPMailer\PHPMailer\PHPMailer->send() #4 /home/www/user/example.net/www/wp-includes/pluggable.php(2159): wp_mail(Array, '[test] New User...', 'New user regist...', Array) #5 /home/www/user/example.net/www/wp-includes/user.php(3439): wp_new_user_notification(4, NULL, 'admin') #6 /home/www/user/example.net/www/wp-includes/class-wp-hook.php(308): wp_send_new_user_notifications(4, 'admin') #7 /home/www/user/example.net/www/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #8 /home/www/user/example.net/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #9 /home/www/user/example.net/www/wp-admin/includes/user.php(241): do_action('edit_user_creat...', 4, 'admin') #10 /home/www/user/example.net/www/wp-admin/user-new.php(195): edit_user() #11 {main} thrown in /home/www/user/example.net/www/wp-includes/PHPMailer/PHPMailer.php on line 874
This issue doesn't exist with PHP 7.4.
Change History (4)
#3
@
2 years ago
If I add in wp-config.php :
function mail() { return; }
then the problem is solved.
#4
@
2 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
@CyberCr33p Thanks for following up and letting folks know you'd resolved the problem.
When disabling commonly available functions in PHP 8, you've arrived at the best solution of adding a dummy function in the wp-config file. Otherwise WordPress would need include an impractical number of function_exists()
checks within the code base.
In ticket #52226 you'll see WordPress made an exception for function calls included prior to the wp-config file being included. After that it's considered an edge case for advanced configurations that can be handled by the server administrators using such configurations.
I'm going to close this off as wontfix due to the impracticality of including all the function_exists()
calls but I'm glad you found the solution.
Thanks,
Peter
https://www.php.net/manual/en/migration80.incompatible.php
Disabled functions are now treated exactly like non-existent functions. Calling a disabled function will report it as unknown, and redefining a disabled function is now possible.