[英]WP_MAIL() not sending attachments
I am working on one plugin in which I need to send email with attachment(s). 我正在开发一个插件,我需要在其中发送带有附件的电子邮件。 I have tried with below code but its not working for me.
我尝试使用下面的代码,但对我不起作用。 Its sending email but without attachment.
它发送电子邮件,但没有附件。 Please guide me if I am doing anything wrong.
如果我做错任何事情,请指导我。
attachment array is as below : 附件数组如下:
[attachments] => Array ( [0] => https://www.xxxx.com/wp-content/uploads/2019/02/test.docx )
[附件] =>数组([0] => https://www.xxxx.com/wp-content/uploads/2019/02/test.docx )
NOTE : I have checked that attachment file has 644 file permission. 注意:我已检查附件文件具有644文件权限。
$attachments = array();
$ attachments = array(); if(isset($email['attachments']) && count($email['attachments'])>0){ $attachments = $email['attachments'];
if(isset($ email ['attachments'])&& count($ email ['attachments'])> 0){$ attachments = $ email ['attachments']; }
}
$headers = array();
$ headers = array();
$headers[] = 'Content-Type: text/html;
$ headers [] ='内容类型:text / html; charset=UTF-8';
字符集= UTF-8' ;
$headers[] = 'From: ' .
$ headers [] ='发件人:'。 $from_name .
$ from_name。 ' <' .
'<'。 $from_address .
$ from_address。 '>';
'>';
if(isset($email['reply_name']) && isset($email['reply_to'])){
if(isset($ email ['reply_name'])&& isset($ email ['reply_to'])){
$headers[] = 'Reply-To: ' . $email['reply_name'] . ' <' . $email['reply_to'] . '>';
}elseif(isset($email['reply_to'])){
} ELSEIF(isset($电子邮件[ 'REPLY_TO'])){
$headers[] = 'Reply-To: <' . $email['reply_to'] . '>';
}
}
wp_mail($email['recipients'], $email['subject'], $email['content'], $headers, $attachments);
wp_mail($ email ['recipients'],$ email ['subject'],$ email ['content'],$ headers,$ attachments);
Thank you in advance. 先感谢您。
Can you give your result for " $attachments " ? 您能否给出“ $ attachments ”的结果?
Thx. 谢谢。
[EDIT] [编辑]
You need a special format to send an attachment : 您需要一种特殊的格式来发送附件:
$attachments = array( WP_CONTENT_DIR . '/uploads/file_to_attach.zip' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.