How do I stop Gmail from stripping the values out of URLs?

后端 未结 4 1850
时光取名叫无心
时光取名叫无心 2021-02-19 20:43

I recently learned that webmail clients like Gmail will do alterations on HTML emails, for example adding target=\"_blank\" to tags.

相关标签:
4条回答
  • 2021-02-19 21:30

    Emailing in html uses Quoted-printable Encoding. The problem with your $mailContent is that the "=" must be represented by =3D

    Try adding this: $mailContent = quoted_printable_encode($mailContent);

    0 讨论(0)
  • 2021-02-19 21:33

    This may not be the perfect answer, but if your application allows for it, I have used URL shorteners a number of times.

    http://goo.gl/ is my preferred because the API is super easy to implement and google is very fast. I have a function in a class and I just run my url through it and send the return wherever I need it to be.

    0 讨论(0)
  • 2021-02-19 21:41

    Click View original/source on the message in Gmail to see if the URLs looks like they should then. If so you know that the problem is how Gmail is formatting the message for your viewing. If it's mutilated even in the source I was wondering if there's anything in your webpage/php/CMS (do you use one) that changes the code.

    You should try URL-encoding as @Crisp said. Here's the W3 reference.

    0 讨论(0)
  • 2021-02-19 21:48

    Another non-perfect answer here but, my problem was that I was including an http url in the html body and apparently is not valid so I changed them to https. This was on a dev environment so no problem on production.

    Here is more info about this:

    Any URL's in the body of the mail which lead to insecure sites may also need to be removed. Use https://transparencyreport.google.com/safe-browsing/search to validate these links.. All links should be correctly prefixed with "https". https://en.wikipedia.org/wiki/HTTPS Google seem to be rejecting "http". Sometimes, but not always, removing links from any signature can help.

    0 讨论(0)
提交回复
热议问题