php 如何在wordpress中发送带有附件的电子邮件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4554664/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 13:26:35 来源:igfitidea点击:
How to send an email with attachment in wordpress?
提问by fms
Now I can send an email without attachment :
现在我可以发送没有附件的电子邮件:
wp_mail( $to, $subject, $message, $headers);
But how can I send an email with attachment?
但是如何发送带有附件的电子邮件?
回答by zod
<?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?>
回答by sandip patil
Refer below e.g.
参考下面例如
$attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');
$headers = 'From: My Name <[email protected]>' . "\r\n";
wp_mail('[email protected]', 'subject', 'message', $headers, $attachments);
回答by user2698703
add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
function mycustom_wpcf7_mail_components( $components ) {
$components['attachments'][] = 'full path of your PDF file';
return $components;
}