[英]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.