Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

preventing gmail from stripping href, target, and id attributes

I'm sending an email from my NodeJS server using Mailgun to a Gmail account, but Gmail strips all the attributes in the email. What is the reason for this and how do I prevent this from happening? I tried encoding the href value using encodeURIComponent but that did nothing for the href tag. I'm also not using any CSS or anything so I'm confused why this is happening.

before:

<a href="/resetpw" id="reset-link" id="reset" target="_blank">Reset Password</a>

after (when I checked the HTML of the email):

<a></a>
like image 837
user3226932 Avatar asked Jul 16 '16 23:07

user3226932


People also ask

Does Gmail strip style tags?

Inlining CSS is great for the general look and feel of an email. But what about handling responsive emails that rely on CSS media queries? The answer is to keep those styles within the head of your email. Yes, Gmail will strip them out when it runs your email through a preprocessor, but that's OK.

How do I turn off automatic hyperlinks in Gmail?

If you would like to disable the automatic Smart Link Previews when composing an email, you can do so by clicking the Right Inbox icon at the top right of your Gmail page and selecting 'Smart Link Preview Settings'. You will then be presented with an option to disabled the feature.

Does Gmail support HTML5?

Gmail uses the HTML5 DOCTYPE.


1 Answers

Gmail is likely stripping your link from the email because of the href value of /resetpw, which, seeing as it's missing a domain name, will refer to https://mail.google.com/resetpw and a) not work and b) potentially be a security hole (I can't think of a way off-hand, but it makes sense to be overly cautious here on Google's part).

Use a valid URL with a scheme and domain/IP (i.e. http://localhost:3000/resetpw), fix the invalid HTML like duplicate id parameters, and it should work just fine.

like image 93
ceejayoz Avatar answered Oct 09 '22 12:10

ceejayoz