我有一封需要發送給第三方的自定義 WooCommerce 電子郵件。在這封電子郵件中,我必須添加一個附件。我試過了,wc_mail()但附件沒有附加。這是它的樣子:$attachment = array();ob_start(); include('some-html-email-content.php');$message = ob_get_clean();$attachment[] = get_template_directory() . '/some.pdf';wc_mail('[email protected]', 'some subject ', $message, "Content-Type: text/html\r\n", $attachment);我可以毫無問題地收到電子郵件,只是附件沒有。我做錯了什么?我不能使用woocommerce_email_attachments過濾器掛鉤,因為此郵件未附加到任何常規的 woocommerce 郵件(新訂單、流程、新用戶等....)。我也嘗試過wp_mail()仍然無法通過。
3 回答

白豬掌柜的
TA貢獻1893條經驗 獲得超10個贊
$attachment = array( WP_PLUGIN_DIR . '/my-plugin/uploads/sample_photo_01.jpg' );
附件應始終使用絕對文件系統路徑。根據附件所在的位置更改文件的位置/名稱。
來源: http: //codex.wordpress.org/Function_Reference/wp_mail http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_content_type

Cats萌萌
TA貢獻1805條經驗 獲得超9個贊
像這樣的東西會起作用嗎?我認為您為數組變量賦值的方式可能不正確?
$getAttachment = get_template_directory() 。'/一些.pdf';
$attachment = array("{$getAttachment}");
更正了,對不起。
- 3 回答
- 0 關注
- 137 瀏覽
添加回答
舉報
0/150
提交
取消