如何阻止Gmail从URL中剥离值? [英] How do I stop Gmail from stripping the values out of URLs?

查看:91
本文介绍了如何阻止Gmail从URL中剥离值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近了解到,像Gmail这样的Gmail邮件客户端会对HTML电子邮件进行修改,例如将 target =_ blank添加到< a> 标签。



我还发现其他更改也会发生。当我从PHP脚本向Gmail(以及其他的网络邮件客户端)发送一封HTML电子邮件时,任何链接的URL中包含的变量值将被删除。所以,例如,这是我在PHP代码中设置的值:

  $ mailContent ='< p> < a target =_ blankhref =https://example.com/confirmation.html?verification=x1x1x1x1x1x1x1x&email=yyyy@email.com>点击此处转到网站并激活您的帐户! < / A>< / p为H.'; 

但是当Gmail中收到电子邮件时,HTML代码如下所示:

 < p>< a target =_ blankhref =https://example.com/confirmation.html?verification=& ; email =>点击此处转到网站并激活您的帐户!< / a>< / p> 

x1x1x1x1x1x1x1x yyyy@email.com 已从< a> 标签中删除。



如何保护我想传递给URL的变量的值,以便Gmail不会删除?

解决方案

在Gmail中的邮件中点击查看原始/来源,查看网址是否如此。如果是这样,您知道问题是Gmail如何格式化您的查看消息。如果在源代码中被破坏,我想知道您的网页/ php / CMS中是否有任何改变代码的东西(您使用的是什么)。



您应该尝试< @Crisp表示,href =http://meyerweb.com/eric/tools/dencoder/ =nofollow> URL编码。以下是 W3参考


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

I've also discovered that other alterations happen as well. When I send an HTML email to Gmail (and possibly other web mail clients) from my PHP script, variable values included in the URL of any links are being stripped out. So, for example, this is the value I'm setting in my PHP code:

$mailContent = '<p><a target="_blank" href="https://example.com/confirmation.html?verification=x1x1x1x1x1x1x1x&email=yyyy@email.com">click here to go to the web site and activate your account!</a></p>';

But when the email is received in Gmail, the HTML code comes out like this:

<p><a target="_blank" href="https://example.com/confirmation.html?verification=&email=">click here to go to the web site and activate your account!</a></p>

The values x1x1x1x1x1x1x1x and yyyy@email.com have been stripped out from within the <a> tag.

How do I protect the values of the variables that I want to pass to the URL so that Gmail won't remove them?

解决方案

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.

这篇关于如何阻止Gmail从URL中剥离值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆