[英]How to send an email with attachment in wordpress?
現在我可以發送沒有附件的電子郵件:
wp_mail( $to, $subject, $message, $headers);
但是,如何發送帶附件的電子郵件?
<?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?>
請參考下文
$attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');
$headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
wp_mail('test@test.com', 'subject', 'message', $headers, $attachments);
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.