attachments - Attach a external file as attachement using wp_mail

admin2025-06-04  1

I am trying to attach external file link (doc file) as attachment but not able to so .. no attachment is being attached..

$email_attachment =  array('/');
wp_mail($admin_email,$email_subject,$email_message,$headers,$email_attachment);

Please help I am stuck

I am trying to attach external file link (doc file) as attachment but not able to so .. no attachment is being attached..

$email_attachment =  array('https://ucarecdn/8aa17c61-bd55-4311-8b45-7d9a2efde6c5/');
wp_mail($admin_email,$email_subject,$email_message,$headers,$email_attachment);

Please help I am stuck

Share Improve this question edited Jan 6, 2019 at 10:02 user7459842 asked Jan 5, 2019 at 15:11 user7459842user7459842 721 silver badge10 bronze badges 2
  • 1 Probably need to use an absolute path in your url. – Tim Hallman Commented Jan 5, 2019 at 15:19
  • Also, make sure the content type is set to text/html. See wp_mail_content_type – Tim Hallman Commented Jan 5, 2019 at 15:20
Add a comment  | 

1 Answer 1

Reset to default 1

You can't attach from a URL. So https://ucarecdn/8aa17c61-bd55-4311-8b45-7d9a2efde6c5/ won't work.

You need an absolute path to the file, such as /path/to/my/file.ext.

But there are some other problems with your code snippet as well. You use $email_attachement (with a ..chement...) in one place, but then $email_attachment in your wp_mail() call. Also, your "attachment" isn't a file. While that may resolve as a URL, that would involve a URL rewrite which isn't going to work for accessing a file to attach.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749039805a315845.html

最新回复(0)