Score:-1

Send HTML mail with plain text mime/alternative (for anti-spam)

us flag

We use Webform Drupal 8 module to handle newsletter subscription on a website. An html formatted email is sent to confirm subscription. Unfortunately, this email is sent with only content-type:text/html, and you know how picky Spamassassin is about this. It's a real deliverability issue. We'd like to be able to send that email with a content-type:multipart/alternative, with 2 parts : one with text/html content-type and one with text/plain. How can we do this ? We installed "mail system" and "mime mail" modules, but we can't figure out how to use them, or even if it's the right solution. Has anyone ever managed to do this?

ru flag
No we don't know that, the spam score for HTML mail is usually completely negligible. Check your mails on mail-tester.com, you're most likely fixing the wrong problem
No Sssweat avatar
ua flag
I agree with @Hudri. Make sure you have added a PSF record, DKIM and DMARC to your DNS. Othewise, you'll likely land in the Spam box.
Philippe Chaissac avatar
us flag
Usually negligible yes, but not for a major french ISP :/ We finally added a text version via hook_mail_alter. With the exception of DKIM, which I expect to be implemented soon in our IS, and which costs us a whole point on mail-tester.com, everything is ok (9/10).
Score:0
fr flag

You can't do this with Drupal core, you need a helper module like Mime Mail.

The Webform module only does the minimum - it sets the content-type header but does not deal with multipart messages, does not deal with embedding images, embedding CSS/JS, re-writing URLs to be absolute, or adding attachments, etc.

The Mime Mail module was specifically written to allow any Drupal module to send multipart/alternative email with the above features.

You say you can't figure out how to use it? There's some really good documentation at https://www.drupal.org/docs/contributed-modules/mime-mail that should help.

Philippe Chaissac avatar
us flag
Thanks, we've finally implemented hook_mail_after to achieve our goal, but we'll take a closer look at mime-mail.
fr flag
I guess I wonder why you bothered to ask - I answered within a few hours of your post but you had already gone off in a different direction. Seems like I wasted my time answering you ...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.