有没有什么技巧可以阻止 Gmail 的“引用文本”?隐藏我的电子邮件页脚?

发布于 2024-10-31 11:14:57 字数 1574 浏览 1 评论 0原文

我向我的用户发送电子邮件,这些电子邮件具有相同的主题,但除页眉和页脚外还包含不同的内容。标头包含徽标、“Part x of n”消息和


并且从不隐藏。页脚包含一个
、相同的“Part x of n”文本和一些我不想隐藏的功能链接(下一步、暂停、推文)。

我尝试将它们包含在

中。我还尝试将 &ts=timestamp 添加到链接中。这些链接是图像,因此我创建了一个名为 image2.png 的符号链接,指向 image1.png 并交替这些图像。这些都不起作用。

有没有我还没有想到的简单解决方案?

这是一些 html:

names are really separated by, rather than just a comma.</p>
<p>This function does not do any checking for problems. We assume,
in this case, that the input is always correct.</p>
</div>
</div>
<div>
<p>All that remains now is putting the pieces together.</div></div></div></div></span>
<hr>(Part 19 of about 74)<br>
<a href='http://www.mywebapp.com/index.php?action=next'>
<img border=0 src='http://www.mywebapp.com/images/next.png' alt='Get next text'</a>&nbsp;&nbsp;
<a href='http://www.mywebapp.com/index.php?action=pause&listid=252&itemid=2100'>
<img border=0 src='http://www.mywebapp.com/images/pause.png' alt='Pause this text'></a>&nbsp;&nbsp;
<a href='http://twitter.com/home?status=tweetGoesHere'><img border=0 src='http://www.mywebapp.com/images/twitter-a.png' alt='Tweet this'/></a><br>
Original page: <a href='http://eloquentjavascript.net/print.html'>here</a><br>

这是屏幕截图:

iPhone snapshot

I send emails to my users which have the same subject but contain different content aside from the header and footer. The header contains a logo, a "Part x of n" message, and an <hr> and is never hidden. The footer contains an <hr>, the same "Part x of n" text and some functional links (Next, Pause, Tweet) that I don't want hidden.

I tried enclosing these in a <div id=timestamp>. I also tried adding &ts=timestamp to the links. The links are images, so then I created a symbolic link called image2.png pointing to image1.png and alternated these images. None of these worked.

Is there a simple solution that I haven't thought of yet?

Here is some html:

names are really separated by, rather than just a comma.</p>
<p>This function does not do any checking for problems. We assume,
in this case, that the input is always correct.</p>
</div>
</div>
<div>
<p>All that remains now is putting the pieces together.</div></div></div></div></span>
<hr>(Part 19 of about 74)<br>
<a href='http://www.mywebapp.com/index.php?action=next'>
<img border=0 src='http://www.mywebapp.com/images/next.png' alt='Get next text'</a>  
<a href='http://www.mywebapp.com/index.php?action=pause&listid=252&itemid=2100'>
<img border=0 src='http://www.mywebapp.com/images/pause.png' alt='Pause this text'></a>  
<a href='http://twitter.com/home?status=tweetGoesHere'><img border=0 src='http://www.mywebapp.com/images/twitter-a.png' alt='Tweet this'/></a><br>
Original page: <a href='http://eloquentjavascript.net/print.html'>here</a><br>

And here's a screenshot:

iPhone screenshot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜巴黎 2024-11-07 11:14:58

这是其他答案中的技术,但这是我添加到 Rails 电子邮件模板中的确切行:

<%# this line makes gmail not quote/fold/hide the message body %>
<span style="color: #FFF; display: none; font-size: 8px;"><%= rand(36**20).to_s(36) %></span>

只需位于不应隐藏的内容下方。

This is the technique from the other answers but this is the exact line that I added to my rails email templates:

<%# this line makes gmail not quote/fold/hide the message body %>
<span style="color: #FFF; display: none; font-size: 8px;"><%= rand(36**20).to_s(36) %></span>

Just needs to go below the content that shouldn't be hidden.

薄暮涼年 2024-11-07 11:14:57

我通过将包含唯一不可见字符串的 附加到电子邮件页脚的每一行来解决此问题。起初,我只是将 time() 添加到每一行,但一些电子邮件客户端将其解释为电话号码并将该字符串转换为 URL。因此,我在字符串前/后添加了一个非数字字符,事情似乎工作正常。

但必须有更好的方法来做到这一点......

I was able to solve this problem by appending a <span> containing a unique invisible string to each line of my email's footer. At first, I just added time() to each line, but some email clients interpret this as a phone number and convert the string into a URL. So, I pre/postpended a non-numeric character to the string and things seem to be working fine.

There must be a better way to do this though...

萌化 2024-11-07 11:14:57

在 Gmail 将我的交易电子邮件分解成块并隐藏其中的重复部分之后,我在我的 meanie-mail-composer 包可以自动为我添加随机字符串。

默认情况下,此帮助程序在每个

标记之前包含一个隐藏的 ,其中包含 5 个字符的随机字符串。

下面是实现此目的的代码片段 (Node.js):

const crypto = require('crypto');

//Helper to randomize HTML contents
function randomize(html, tag = '</p>') {

  //Create a 5 char random string for email content to be unique
  const time = String(Date.now());
  const hash = crypto
    .createHash('md5')
    .update(time)
    .digest('hex')
    .substr(0, 5);

  //Create HTML string to replace with and regex
  const str = `<span style="display: none !important;">${hash}</span>${tag}`;
  const regex = new RegExp(tag, 'g');

  //Replace in HTML
  return html.replace(regex, str);
}

不再有破碎的电子邮件!

After going crazy from Gmail breaking up my transactional emails into blocks and hiding repeating parts of it, I implemented a helper function inspired by SeanO's answer in my meanie-mail-composer package to automate the addition of random strings for me.

This helper includes a hidden <span> with a 5 character random string before every </p> tag by default.

Here's the code snippet that does the trick (Node.js):

const crypto = require('crypto');

//Helper to randomize HTML contents
function randomize(html, tag = '</p>') {

  //Create a 5 char random string for email content to be unique
  const time = String(Date.now());
  const hash = crypto
    .createHash('md5')
    .update(time)
    .digest('hex')
    .substr(0, 5);

  //Create HTML string to replace with and regex
  const str = `<span style="display: none !important;">${hash}</span>${tag}`;
  const regex = new RegExp(tag, 'g');

  //Replace in HTML
  return html.replace(regex, str);
}

No more broken up emails!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文