我通过functions.php 设置了一个wordpress 站点,以将SMTP 与PHPMailer 结合使用(下面的代码片段)。add_action( 'phpmailer_init', 'setup_phpmailer_init' );function setup_phpmailer_init( PHPMailer $phpmailer ) { $phpmailer->Host = 'HOSTNAME'; // for example, smtp.mailtrap.io $phpmailer->Port = 587; // set the appropriate port: 465, 2525, etc. $phpmailer->Username = 'YOURUSERNAME'; // your SMTP username $phpmailer->Password = 'YOURPASSWORD'; // your SMTP password $phpmailer->SMTPAuth = true; $phpmailer->SMTPSecure = 'tls'; // preferable but optional $phpmailer->IsSMTP();除了 WooCommerce 之外,这对所有内容都没有问题。WooCommerce 无法发送电子邮件,并出现以下错误:2020-08-18T00:36:33+00:00 CRITICAL Uncaught TypeError: Argument 1 passed to setup_phpmailer_init() must be an instance of PHPMailer, instance of PHPMailer\PHPMailer\PHPMailer given, called in PathToWordpress/web/wp/wp-includes/class-wp-hook.php on line 287 and defined in PathToWordpress/web/app/themes/theme-name/functions.php:362Stack trace:#0 PathToWordpress/web/wp/wp-includes/class-wp-hook.php(287): setup_phpmailer_init()#1 PathToWordpress/web/wp/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()#2 PathToWordpress/web/wp/wp-includes/plugin.php(544): WP_Hook->do_action()#3 PathToWordpress/web/wp/wp-includes/pluggable.php(494): do_action_ref_array()#4 PathToWordpress/web/app/plugins/woocommerce/includes/class-wc-emails.php(650): wp_mail()#5 PathToWordpress/web/wp/wp-includes/class-wp-hook.php(287): WC_Emails->no_stock()#6 PathToWordpress/web/wp/wp-includes/class-wp-hook.php(311): WP_Hook->apply in PathToWordpress/web/app/themes/theme-name/functions.php on line 362可能是什么原因导致此错误?
1 回答
开心每一天1111
TA贡献1836条经验 获得超13个赞
转动这条线:
函数 setup_phpmailer_init( PHPMailer $phpmailer) {
进入此(删除 PHPMailer)修复了错误
函数 setup_phpmailer_init($phpmailer) {
我不完全确定为什么
- 1 回答
- 0 关注
- 82 浏览
添加回答
举报
0/150
提交
取消