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.com/8aa17c61-bd55-4311-8b45-7d9a2efde6c5/');

Please help I am stuck

  • 1
    Probably need to use an absolute path in your url. Jan 5, 2019 at 15:19
  • Also, make sure the content type is set to text/html. See wp_mail_content_type Jan 5, 2019 at 15:20

1 Answer 1


You can't attach from a URL. So https://ucarecdn.com/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.

  • thanks for your inputs.. please excuse the spelling mistakes . i have edited it above.. but how do i get started .. so do I create the temporary file from contents of the doc file on the url and then use it .. not getting how to move forward Jan 6, 2019 at 10:06
  • After re-reading your question (and the title), it seems like the file is remote (not on the same server)? There's not a direct way to do that. You'd need to incorporate a process of retrieving the file and saving it locally so you could attach it.
    – butlerblog
    Jan 6, 2019 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.