I am trying to send an attachment with webform and MIMEmail. It is not working. I've got an attachment set up, I've gotten the latest dev versions (and tested on the last stable versions) of both modules, I've attached a file to the webform node, and I've selected "send files as attachments".

No luck.

The email still comes through, absolutely no problem, but there are no attachments.

Comments

quicksketch’s picture

Category: bug » support
Status: Needs review » Active

I've attached a file to the webform node, and I've selected "send files as attachments".

You may be misunderstanding this functionality. This feature doesn't send files attached to the Webform node (supposedly through FileField in your situation) in the e-mail. It sends files uploaded through file components as part of the submission.

Some related requests:
#1744870: csv file attachment
#1262096: Attachments: Handbook page on using mimemail with webform to send emails with files as attachments

andy.alexander’s picture

Through file components? I am not understanding.

I had already read the second link you sent and thought I was doing it correctly. Do you happen to have any documentation that could explain it more clearly?

andy.alexander’s picture

So, is there a way to have a file sent from elsewhere on submission of a form? That is pre-uploaded and not dependent on a user's upload?

quicksketch’s picture

There isn't a built-in feature to send a pre-configured file to be sent along with the e-mail, no. .Though a number of modules such as http://drupal.org/project/webform2pdf and http://drupal.org/project/fillpdf provide functionality like this (though these only deal with PDFs). Through custom coding, you can attach any file you want through hook_mail_alter().

andy.alexander’s picture

These both seem to generate the file automatically - one (Webform2pdf) converts the output of the form to a PDF and then sends it. That's not what I'm looking for.

The other seems to allow you to insert information into PDFs which you then send.

The easiest way I can see to do it would be to edit webform2pdf to send any type of file - is that more or less correct? I've never modified a mail function in Drupal.

quicksketch’s picture

I would suggest a completely custom module. If you're not comfortable with writing modules, I'd suggest hiring a developer or (if you're technically inclined) reading a book on module development for Drupal. I generally don't provide help on custom coding in the Webform issue queue.

jphelan’s picture

This can be done with rules. You just need the following modules:
http://drupal.org/project/mimemail (Be sure to also enable Mime Mail Action)
http://drupal.org/project/rules
http://drupal.org/project/webform_rules

Then create a new rule for "After a webform has been submitted"
Add the "Select a webform" as a condition and select your webform
Then select the mimemail "Send an HTML mail to an arbitrary mail address" action NOT the system "Send a mail to an arbitrary mail address"

You can then use tokens to send the email to an address the user submits in the form. Add your attachments in your attachments box and your all set to go.

jphelan’s picture

Also if anonymous users are submitting the form they need the "send arbitrary files" permission or the attachment won't be sent.

quicksketch’s picture

Status: Active » Closed (fixed)

Thanks @jphelan. I don't generally recommend Rules for anything (it makes debugging nearly impossible), but if it works then power to you. Closing after lack of activity.