Handle sending email in Drupal CMS

Created on 15 October 2024, about 1 month ago

Problem/Motivation

Drupal doesn't do email so well OOTB. We have a few features that require it, such as the contact form sending notification emails, but we also don't want to enable email sending in WASM because you could use that for spamming.

Making a plan issue for this initially to discuss the considerations and limitations.

Proposed resolution

At DrupalCon Barcelona, we discussed options with the core committers, because we anticipate this will eventually be solved somehow in core and wanted to ensure we go in the right direction. We decided the least worst option is for Drupal CMS to use Symfony Mailer Lite, which relies on Mailsystem. Then when we fix core email it will be able to move with that easier. This is documented in πŸ“Œ [meeting] Drupal core email handling discussion Fixed

However, we didn't get into specifics of what to configure by default, and how to handle scenarios such as WASM where we want to ensure email sending is NOT enabled.

🌱 Plan
Status

Active

Component

Base Recipe

Created by

πŸ‡¦πŸ‡ΊAustralia pameeela

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

Comments & Activities

  • Issue created by @pameeela
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    I wouldn't worry about the Wasm runtime - there is a hidden module that is installed for the trial only, which imposes certain runtime limitations. We could add something to that module which would unconditionally send all Drupal mail to the big hard drive in the sky.

  • πŸ‡¨πŸ‡¦Canada mandclu

    I would argue that if a goal of Starshot / Drupal CMS is to create a more modern "out of the box" experience, Drupal should be able to send HTML emails. The Easy Email module (which works with Symfony Mailer Lite and is by the same maintainer) is designed to simplify sending HTML emails. Maybe that doesn't need to be part of the MVP / Jan 2025 target, but I think it should be on the roadmap.

  • πŸ‡ΊπŸ‡ΈUnited States ben.hamelin Adirondack Mountains, NY

    Any technical solution exclusively in Drupal code is always going to run up against the hosting environment limitations. One way I could see this working would be with a SMTP server provided by the Drupal Association. You would then need an account on d.o. plus DNS configuration to enable sending. Then the service could be supported $$ wise by association funds, donations, etc.

  • πŸ‡¨πŸ‡¦Canada mandclu

    FYI there is now a recipe for setting up Easy Email. We should definitely evaluate Easy Email: Express Mail β†’ for inclusion in Drupal CMS

  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    I'm the maintainer of Symfony Mailer Lite and Easy Email. If there's anything I can do to assist with this effort, please let me know. Both the Easy Email module and the recipe are somewhat opinionated in their defaults, with the goal of making things as easy as possible to set up. Some of those defaults may not be the best choice for something included in Drupal CMS. I'm happy to help with setting up a different recipe or adding more configuration options or features to the underlying Easy Email module or theme.

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    @zengenuity thank you! Opinionated is good IMO, that's what we're here to do :)

    I'd be happy to start with the standard recipe, unless there are specific things that you think we might want to do differently? I'm no expert on mail systems so for my part I don't have strong opinions.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    As we also still have the pending topic of notifications in Drupal CMS, which will have to utilise the Easy Email capabilities as well, I'd be interested in this improved setup by @zengenuity so that we can build the notifications by ECA by using all this in the best possible way, too.

  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    Here are four things I think we should review for Easy Email in Drupal CMS.

    1. Storing sent emails: By default, Easy Email stores all sent emails, which are then visible to review under Reports > Emails. (Security-related tokens like one-time login URLs are stripped out before saving.) For sites with a lot of users, this may increase the database size quickly. This functionality is configurable per template. So, we can decide to turn it off for all core emails or for specific ones.

    2. Truncating sent email log: Each template has a setting to automatically delete the sent emails of that type from the database a certain number of days after sending. By default, this feature is disabled, and it's currently disabled on the core templates in the Easy Email Express Mail recipe. This functionality runs on cron, and there is a global setting that allows you to configure the maximum number of emails to delete on each cron run. The default is 50.

    3. Theme: The recipe includes the Easy Email Theme β†’ , which is an extremely simple theme that I created specifically for sending emails. The design is very basic. There's a grey body background, white content background, and then your email content is in there. It does have a header inside the white box which will include either your site name or logo if they are configured in the Easy Email Theme. The default theme logo is the Drupal logo, the result of which you can see on the Easy Email Theme page as a screenshot. What I have is functional, but it perhaps could be improved. I'm more of a backend dev, so the design stuff is not my forte.

    4. Disabling the core email template edit form: In the recipe, all the core user-related emails are overridden by Easy Email. However, you can still see the editing boxes for them under Configuration > People > Account settings. This could be confusing for users, since editing the email templates there will do nothing. You need to edit the templates in Easy Email. I was planning to add a feature to the Easy Email Overrides submodule that would disable/hide the appropriate email elements on this page when they've been overridden by Easy Email. I was going to replace the form elements with a link to the related Easy Email template edit page. I think this feature would be important to have for Drupal CMS, but it's not built yet.

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    @zengenuity thanks! Agree the storage could be an issue, and also that we should truncate the logs. Re: overriding the account settings form, do you have an issue for that? If you wanted to create one with a bit of a plan, we could try to point people at it as a contribution opportunity?

    In the meantime, I think we can start with the existing recipe and tweak it from there. Since this is a plan issue, I'll open a separate one.

  • πŸ‡¦πŸ‡ΊAustralia pameeela
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    Thanks everyone, we have a recipe for this in Drupal CMS now and a plan for how to document the ideal setup.

Production build 0.71.5 2024