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>
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.
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.
Gmail uses the HTML5 DOCTYPE.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With