我通過(guò)functions.php 設(shè)置了一個(gè)wordpress 站點(diǎn),以將SMTP 與PHPMailer 結(jié)合使用(下面的代碼片段)。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 之外,這對(duì)所有內(nèi)容都沒(méi)有問(wèn)題。WooCommerce 無(wú)法發(fā)送電子郵件,并出現(xiàn)以下錯(cuò)誤: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可能是什么原因?qū)е麓隋e(cuò)誤?
1 回答

開(kāi)心每一天1111
TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超13個(gè)贊
轉(zhuǎn)動(dòng)這條線:
函數(shù) setup_phpmailer_init( PHPMailer $phpmailer) {
進(jìn)入此(刪除 PHPMailer)修復(fù)了錯(cuò)誤
函數(shù) setup_phpmailer_init($phpmailer) {
我不完全確定為什么
- 1 回答
- 0 關(guān)注
- 121 瀏覽
添加回答
舉報(bào)
0/150
提交
取消