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 )
NOTE : I have checked that attachment file has 644 file permission.
$attachments = array(); if(isset($email['attachments']) && count($email['attachments'])>0){ $attachments = $email['attachments']; }
$headers = array();
$headers[] = 'Content-Type: text/html; charset=UTF-8';
$headers[] = 'From: ' . $from_name . ' <' . $from_address . '>';
if(isset($email['reply_name']) && isset($email['reply_to'])){
$headers[] = 'Reply-To: ' . $email['reply_name'] . ' <' . $email['reply_to'] . '>';
}elseif(isset($email['reply_to'])){
$headers[] = 'Reply-To: <' . $email['reply_to'] . '>';
}
wp_mail($email['recipients'], $email['subject'], $email['content'], $headers, $attachments);
Thank you in advance.