WooCommerce结账时触发PHPMailer致命错误排查求助
WooCommerce结账触发严重错误的解决方案
错误根源
从日志可以确定,问题出在服务器PHP环境未启用mail()函数。结账完成后WooCommerce会自动发送新订单通知邮件,调用wp_mail()时,底层PHPMailer尝试调用系统mail()函数,但该函数被禁用或不存在,直接触发致命错误。
解决步骤
1. 检查PHP配置
- 登录服务器控制面板(如cPanel、Plesk),找到PHP设置
- 查看
disable_functions列表,若包含mail则移除该条目 - 虚拟主机用户直接联系服务商,确认是否开启PHP邮件功能
2. 切换SMTP发送邮件
如果无法启用系统mail()函数,改用SMTP是更稳定的替代方案:
- 后台安装SMTP类插件(如WP Mail SMTP)
- 配置SMTP服务器信息(可使用第三方邮箱或主机提供的SMTP服务)
- 测试邮件发送,确保配置生效
3. 临时禁用订单邮件(应急)
若需快速恢复结账流程:
- 进入WooCommerce设置→邮件→新订单
- 取消勾选“启用此电子邮件通知”并保存
- 问题解决后记得重新开启,避免遗漏订单通知
中文翻译后的错误日志
[2024年9月25日 11:11:23 UTC] PHP致命错误:未捕获错误:调用未定义的函数PHPMailer\PHPMailer\mail(),文件路径:/home/bontonst/public_html/wp-includes/PHPMailer/PHPMailer.php:881 堆栈跟踪: #0 /home/bontonst/public_html/wp-includes/PHPMailer/PHPMailer.php(1972): PHPMailer\PHPMailer\PHPMailer->mailPassthru() #1 /home/bontonst/public_html/wp-includes/PHPMailer/PHPMailer.php(1693): PHPMailer\PHPMailer\PHPMailer->mailSend() #2 /home/bontonst/public_html/wp-includes/PHPMailer/PHPMailer.php(1525): PHPMailer\PHPMailer\PHPMailer->postSend() #3 /home/bontonst/public_html/wp-includes/pluggable.php(546): PHPMailer\PHPMailer\PHPMailer->send() #4 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(741): wp_mail() #5 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/emails/class-wc-email-new-order.php(112): WC_Email->send() #6 /home/bontonst/public_html/wp-includes/class-wp-hook.php(324): WC_Email_New_Order->trigger() #7 /home/bontonst/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #8 /home/bontonst/public_html/wp-includes/plugin.php(565): WP_Hook->do_action() #9 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/class-wc-emails.php(172): do_action_ref_array() #10 /home/bontonst/public_html/wp-includes/class-wp-hook.php(324): WC_Emails::send_transactional_email() #11 /home/bontonst/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #12 /home/bontonst/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #13 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/class-wc-order.php(420): do_action() #14 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/class-wc-order.php(253): WC_Order->status_transition() #15 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/class-wc-order.php(365): WC_Order->save() #16 /home/bontonst/public_html/wp-content/plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php(390): WC_Order->update_status() #17 /home/bontonst/public_html/wp-content/plugins/woocommerce/src/StoreApi/Legacy.php(54): WC_Gateway_BACS->process_payment() #18 /home/bontonst/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\StoreApi\Legacy->process_legacy_payment() #19 /home/bontonst/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #20 /home/bontonst/public_html/wp-includes/plugin.php(565): WP_Hook->do_action() #21 /home/bontonst/public_html/wp-content/plugins/woocommerce/src/StoreApi/Utilities/CheckoutTrait.php(83): do_action_ref_array() #22 /home/bontonst/public_html/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/Checkout.php(349): Automattic\WooCommerce\StoreApi\Routes\V1\Checkout->process_payment() #23 /home/bontonst/public_html/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/AbstractRoute.php(119): Automattic\WooCommerce\StoreApi\Routes\V1\Checkout->get_route_post_response() #24 /home/bontonst/public_html/wp-content/plugins/woocommerce/src/StoreApi/Routes/V1/Checkout.php(138): Automattic\WooCommerce\StoreApi\Routes\V1\AbstractRoute->get_response_by_request_method() #25 /home/bontonst/public_html/wp-includes/rest-api/class-wp-rest-server.php(1230): Automattic\WooCommerce\StoreApi\Routes\V1\Checkout->get_response() #26 /home/bontonst/public_html/wp-includes/rest-api/class-wp-rest-server.php(1063): WP_REST_Server->respond_to_request() #27 /home/bontonst/public_html/wp-includes/rest-api/class-wp-rest-server.php(439): WP_REST_Server->dispatch() #28 /home/bontonst/public_html/wp-includes/rest-api.php(420): WP_REST_Server->serve_request() #29 /home/bontonst/public_html/wp-includes/class-wp-hook.php(324): rest_api_loaded() #30 /home/bontonst/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #31 /home/bontonst/public_html/wp-includes/plugin.php(565): WP_Hook->do_action() #32 /home/bontonst/public_html/wp-includes/class-wp.php(418): do_action_ref_array() #33 /home/bontonst/public_html/wp-includes/class-wp.php(813): WP->parse_request() #34 /home/bontonst/public_html/wp-includes/functions.php(1336): WP->main() #35 /home/bontonst/public_html/wp-blog-header.php(16): wp() #36 /home/bontonst/public_html/index.php(17): require('/home/bontonst/...') #37 {main} 抛出位置:/home/bontonst/public_html/wp-includes/PHPMailer/PHPMailer.php 第881行
内容的提问来源于stack exchange,提问作者LEVANCHIKA
相关产品推荐
相关产品推荐

