eladnava/mailgen

Remove copyright from plaintext e-mails

eladnava opened this issue · 6 comments

Currently, we output the copyright in plaintext e-mails. I think this is invalid, not to mention the fact that it currently contains HTML tags / entities:

Hi John Appleseed,

Welcome to Mailgen! We're very excited to have you on board.

To get started with Mailgen, please click here:
https://mailgen.js/confirm?s=d9729feb74992cc3482b350163a1a010

Need help, or have questions? Just reply to this email, we'd love to help.

Yours truly,
Mailgen

&copy; 2016 <a href="https://mailgen.js/" target="_blank">Mailgen</a>. All rights reserved.

In any case, it is broken. We should either remove it entirely or decode the HTML entities / remove tags.

Any thoughts?

vuchl commented

Links could be parsed like Linktext: Url to make it clear.

The HTML entities could be parsed to their equivalent unicode symbol if we target UTF-8 as the character set.

I think an easier and cleaner solution would be to simply strip the plaintext e-mail of all HTML tags and convert HTML entities to their corresponding symbols.

But I think we should start with operating on just the copyright object and leave the rest as is, so that we don't break anyone's e-mail if they didn't expect us to strip tags and HTML entities from it.

What do you think?

vuchl commented

Alright, isolating this is a good idea. And since the he package is already referenced/used else where it would simple be wrapping https://github.com/eladnava/mailgen/blob/master/index.js#L26 into an he.decode() imho.

We don't want to wrap the copyright in #L26 specifically because we do want the copyright to have HTML tags and entities when generating a standard HTML e-mail with Mailgen.

We only want to omit these in plaintext e-mails, which would make #L105 an appropriate place:

return output;

I am actually re-considering converting all HTML entities in plaintext e-mails and stripping all tags as a viable option. Even if anyone is using Mailgen to send these, e-mail clients aren't expecting to receive them and will simply display them in plaintext without converting them into their appropriate unicode characters / parsing the HTML tags.

I think he would be appropriate for this, but I think we need more than the decode function. That function will only decode entities, it won't strip the HTML tags. We could either use regular expressions or something like striptags.

Anyone up for this?

vuchl commented

I will look at it over the weekend if you want. Don't have the spare time the next few evenings.