- Issue created by @a.kahn
- 🇳🇱Netherlands Krilo_89
We're having the same issue with 6.3.0-beta2.
Files uploaded to the webform are not send as attachment through mail. The links towards the private files are inside the webform submission, but the users who receive those emails, don't have acces to private drupal files.
- 🇧🇪Belgium bpironet
Not sure if my issue is related but we had the same problem and rolled back to 6.2.9, but the issue was still there.
After investigation, we understood that it was not related to Webform, but to Symfony Mailer due to this change: https://www.drupal.org/project/symfony_mailer/issues/3382624 📌 embedFromPath API addition (for #3284140) Needs work
Now, private files are ignored in emails unless they are explicitly authorized by custom code.We created a custom EmailAdjuster plugin to allow private files to be attached to emails.
namespace Drupal\your_module\Plugin\EmailAdjuster; use Drupal\Core\Access\AccessResult; use Drupal\symfony_mailer\EmailInterface; use Drupal\symfony_mailer\Processor\EmailAdjusterBase; /** * Defines the Attachment access Email Adjuster used for webform. * * @EmailAdjuster( * id = "custom_webform_mailer_attachment_access", * label = @Translation("Webform Attachment access"), * description = @Translation("Grant basic attachment access to webform emails."), * automatic = TRUE, * weight = 100, * ) */ class WebformAttachmentAdjuster extends EmailAdjusterBase { /** * {@inheritdoc} */ public function postRender(EmailInterface $email): void { // Loop through attachments and authorize those coming from form. foreach ($email->getAttachments() as $attachment) { if (...custom logic based on $email content...) { $attachment->setAccess(AccessResult::allowed()); } } } }
Regarding the custom logic to detect that the mail is from webform, you can add a custom header containing the webform_id via hook_mail_alter and try to detect it in the custom logic with: $email->getHeaders()->get('X-Drupal-Webform-ID')?->getBody();
After that, the private attachments should be correctly included in your emails.