Sending attachments using swiftmailer

Created on 13 April 2022, about 2 years ago
Updated 11 October 2023, 9 months ago

Hello, I'm trying to send attachments via swiftmailer programatically, however something seems to be wrong. I read the README.TXT and the documentation for sending attachments ( https://www.drupal.org/node/1590190 โ†’ ). There are some discrepancies between both:

The first indicates that the file should be passed to $message['files'] while the latter to $message['params]['files].

I decided to dig inside the module code and found that the mail() function expects the files to be in $message['params']['files'] and this is where it gets tricky. In my custom module I defined the $message['params'] accordingly with the documentation and nothing happened so I came back to the module code and added some variable dumps to see what happened. What I found was that no matter what I did in my hook_mail() the $message['params] variable never appear in the swift mailer mail() function. If I defined something like $message['params1] or $message['random_string'] the variables are passed to the mail() function however $message['params] never is. Am I missing something? Does anyone have a working example of adding attachments in your hook_mail()?

Just as a note I tested the hook_swiftmailer_attach() function and using this the file is attached

๐Ÿ’ฌ Support request
Status

Closed: works as designed

Version

2.2

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡นPortugal nsalves

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024