Problem/Motivation

Legacy emails commonly list attachments in $params['attachments']. We can support these by converting to Symfony Mailer attachments.

Proposed resolution

Roughly based on SwiftMailer::mail().

Remaining tasks

  1. Some code - possibly older - uses $params['files'] and $params['images']. We won't implement this at first, however
  2. The implementation uses the default Symfony MIME type guesser which is potentially slightly different from the Drupal one. If needs be we could later change this.

User interface changes

API changes

Data model changes

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Issue summary: View changes
adamps’s picture

Issue summary: View changes
nojj’s picture

Issue summary: View changes

is anyone working on this?
seems this patch is a good starting point.
I could help testing.

adamps’s picture

I linked a different patch in the issue summary. The patch mentioned in #4 is more complicated because it combines two topics - this issue, plus some work towards security. I would like to handle security in a separate issue (it hasn't been raised yet).

nojj’s picture

hey AdamPS the patch you linked, does not send attachments for me.

adamps’s picture

the patch you linked, does not send attachments for me.

Please describe what you did to test it.

nojj’s picture

 Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2022-04-21/attachments-support-3261807-send-attachments-from-params.patch

for alpha10 and latest dev

adamps’s picture

Status: Active » Needs work

OK, so the patch needs re-roll, and there are comments in the "Remaining Tasks" section of the IS.

If someone writes a patch I will commit it, but I don't have time to write the patch myself at the moment.

adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new3.55 KB

OK here is a rough idea how it would work, but not actually tested and missing one part.

Please review/test and let me know any comments.

nojj’s picture

Thanks!
Patch applies to alpha10 and sends correct PDF Invoice attachment with commerce invoice.

adamps’s picture

Great thanks @nojj.

I checked and Symfony already does some MIME type guessing with a big array in Symfony\Component\Mime\MimeTypes. It might not be identical to Drupal, but arguably it's better - not clear why Drupal has to reimplement this. So I'm going to remove the @todo comment and commit.

adamps’s picture

Status: Needs review » Fixed

  • AdamPS committed 1c4c5b6 on 1.x
    Issue #3284142 by AdamPS, nojj: Add support to attachments for...
adamps’s picture

Status: Needs review » Fixed
adamps’s picture

Issue summary: View changes
adamps’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

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

luenemann’s picture

Version: 1.x-dev » 1.0.0-alpha11
Parent issue: » #3261807: [META] Attachments support