$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>attachments - Attach a external file as attachement using wp_mail|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

attachments - Attach a external file as attachement using wp_mail

matteradmin10PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far