preventing gmail from stripping href, target, and id attributes

北城余情 提交于 2019-12-04 04:21:30

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/38416676/preventing-gmail-from-stripping-href-target-and-id-attributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!