Mailto links in Discourse emails are botched

AI-generated summary

Mailto links in Discourse emails are botched

A bug was reported where mailto links in Discourse emails are incorrectly formatted, causing issues with some email hosts flagging the emails as suspicious. The bug was identified by lkramer, who noted that when a post contains an email address, the underlying HTML in the email is incorrect, resulting in a link that starts with the forum URL instead of the “mailto:” protocol.

lkramer further verified that this issue occurs in all three types of emails sent by Discourse: activity summary emails, mailing list mode emails, and daily digest emails. jomaxro confirmed the issue and provided an example of the broken HTML. codinghorror assigned the task to neil, who has since fixed the bug and ported the fix to the stable branch.

Hello. A user of ours recently pointed this bug out out. It wouldn’t be too big of a deal except that his web host (Lunar Pages) actually flags his Discourse emails as suspicious because of this and perhaps other email/hosts might as well.

Let’s say someone makes a post in Discourse like:

Hi there. I can help you. Email me at username@domain.com.

Discourse properly turns that into a “mailto” link on the forum itself. But when that post appears in a Discourse email, the underlying html is:
<a href="https://www.forumurl.commailto:username@domain.com">username@domain.com</a>

Instead of:
<a href="mailto:username@domain.com">username@domain.com</a>

Is this happening to others as well?

5 Likes

Are you referring to email or the post body? @jomaxro can you test in an email just to see?

1 Like

In emails that Discourse sends out (e.g. mailing list mode emails), any email address within in a post gets mucked up like so:

<a href="https://www.forumurl.commailto:username@domain.com">username@domain.com</a>

1 Like

In case this is helpful, I just verified that this happens to us in all three types of emails that Discourse sends:

  1. Activity summary emails (“Since your last visit…”)
  2. Mailing list mode emails
  3. Daily digest emails (no longer a part of Discourse but someone wrote us a plugin for this which copied the old code for this)
2 Likes

OK cool @neil can I add this to your plate to fix? We should maybe backport the fix too.

I can confirm this (sorry for the delay) - the HTML definitely appears broken in the raw email. This affects standard email notifications (watching a topic, mentioned, etc) in addition to the emails mentioned above.

<a href="https://try.discourse.orgmailto:test@example.com" style="text-decoration: none; font-weight: bold; color: #006699;">test@example.com</a>
4 Likes

This bug is fixed, and ported to the stable branch.

4 Likes