I want to attach a PDF with webform2pdf module to the e-mails, containing the submitted webform values.
This works flawlessly, if the mimemail module doesn't exists. Otherwise, it accepts the attachment in an array, which is given by webform, but this variable isn't accessible externally.
This hook tries to solve this problem.

Comments

mr.york’s picture

StatusFileSize
new1.18 KB

Patch.

mr.york’s picture

Status: Active » Needs review
quicksketch’s picture

Status: Needs review » Needs work

Is this hook really necessary? Could we just pass attachments along in $mail_params variable, which is then accessible in hook_mail_alter()? Adding another hooks when another hooks is called in the exact same place seems wasteful.

mr.york’s picture

Great idea, but i doubt it will work, because drupal_mail() doesn't accepts parameters as reference (http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/6). Parameter will not be usable in hook_mail_alter() (http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...).

quicksketch’s picture

drupal_mail() doesn't need to take things by reference, it returns the $message array to Webform, which Webform then could use to send the e-mail. The $message array is passed by reference in hook_mail_alter().

mr.york’s picture

Status: Needs work » Needs review
StatusFileSize
new925 bytes

Second attempt.

quicksketch’s picture

Version: 6.x-3.x-dev » 6.x-3.9
Status: Needs review » Fixed
StatusFileSize
new1.2 KB

Not quite what I meant but close enough I could adapt the patch easily. This patch should fix the problem and I've committed it to Git.

quicksketch’s picture

Title: New hook_webform_submission_send_mail_attachments_alter hook, if mimemail module exists. » Allow altering of attachments in hook_mail_alter()
mr.york’s picture

Thank you!

roderik’s picture

The committed patch doesn't actually work - $message['attachments'] does not contain the attachments.

See #1162112-17: Mime Mail error after upgrade Webform for followup. That issue gets much more traffic than this one, so I won't change statuses.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.