Sending email with attachment

Pierre Buyle picture Pierre Buyle · Aug 22, 2010 · Viewed 11.8k times · Source

I've a custom form (created with form API) that need send an uploaded file by email. The current form submit handler sends the email without attachment using drupal_mail().

So I'm looking for a solution to properly send email with attachment from Drupal. Mime Mail seems an overkill because HTML mail, templating and its other features are not required. But the only other alternative I see is to set the appropriate headers and serialize the attached file in the mail body when processing the mail in my hook_mail() implementation.

Did I miss anything? Is there any module to handle this?

Answer

Omar Ali picture Omar Ali · Aug 22, 2010

Mimemail is the easiest solution here. Be it an overkill or not, it will allow you to get it done with a single function call.

If you insist, you may have your homemade attachment sender: base64 encode your attachment(s), add them to the mail body, add the correct headers and you're done.