0

I came across a problem with WP_Mail for sending form submissions with file attachments. Our site uses a CDN, so everything uploaded to the site, whether images and media by site builders or documents by users gets put on an external server.

This poses a problem for WP_Mail because it uses the PHPMailer addAttachment method to attach files, which expects local files. I was able to fix this by changing the line in wp_mail to use addStringAttachment, but of course modifying core files isn't really a fix. What is the right way to do this?

Thanks.

1
  • you can always write the file to a temporary folder, attach it, send, then delete it
    – Tom J Nowell
    Commented Feb 16, 2022 at 16:31

1 Answer 1

0

Solved by Tom J Nowell's suggestion. Our form plugin fortunately has a filter before the data is passed to wp mail, so there I was able to swap the attachment url for one pointing to the temporary folder.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 19, 2022 at 21:08

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.