Ruby:邮件宝宝在邮件中添加了60个字符后添加\r\\\<br/> [英] Ruby: Mail gem add \r\n after 60 chars in mail

查看:177
本文介绍了Ruby:邮件宝宝在邮件中添加了60个字符后添加\r\\\<br/>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 actionmailer_x509 移植到Rails 3.为了做到这一点,我尝试创建邮件

I want to port actionmailer_x509 to Rails 3. In order to do that I try to create Mail object from big string with signed email.

您可以在此行上看​​到这样的创建: https://github.com/petRUShka/actionmailer_x509/blob/master/lib/actionmailer_x509.rb#L129

You can see such creation on this line: https://github.com/petRUShka/actionmailer_x509/blob/master/lib/actionmailer_x509.rb#L129

原始字符串( smime0 ): https: /gist.github.com/1d2c84cc2e255be010a6

导致邮件对象转储到文件( newm ): https://gist.github.com/4682fe88e8dcfeca60b2

Resulted Mail object dumped to file(newm): https://gist.github.com/4682fe88e8dcfeca60b2

例如您可以看到 smime0 的第26行和 newm 的第40行之间的区别。在每个64个字符之后,在 smime0 \r\\\
中设置,而在 newm \r\\\
在每60个字符之后设置。

For example, you can see the difference between line 26 of smime0 and line 40 of newm. In smime0 \r\n is setted after each 64 chars, and in newm \r\n is setted after each 60 chars.

此类行为破坏了签名。是否可以改变这种行为?我试图找出如何关闭它,但失败了。

Such behaviour brokes signature. Is it possible to change this behaviour? I tried to find out how to turn off it, but was failed.

可能还有一些其他的解决方法。

May be there is some other workaround for this point.

PS邮件宝石: https://github.com/mikel/mail ,有关x509和actionmailer的讨论主题:如何发送签名来自Rails 3中的ActionMailer的电子邮件

P.S. Mail gem: https://github.com/mikel/mail, thread with discussion about x509 and actionmailer: How do I send signed emails from ActionMailer in Rails 3?

推荐答案

回车不应该是一个问题,因为解析器将知道它是base64编码(并将丢弃 \r\\\
)。

The carriage returns shouldn't be a problem, because the parser will know that it's base64 encoded (and will discard \r\n).

我认为错误来了来自 Content-id 。我发现在您的邮件样本中,newm添加了Content-ID字段,并更改了签名的邮件(尝试删除Content-ID行并验证邮件)。

I think the error comes from the Content-id. I see that in your mail samples, newm adds a Content-ID field, and it changes the signed message (try to remove the Content-ID line and verify the message).

可能的解决方法:


  • 修复邮件宝石以防止添加Content-ID

  • 在签名之前添加一个Content-ID,因为邮件将保留它(如果有)

这篇关于Ruby:邮件宝宝在邮件中添加了60个字符后添加\r\\\<br/>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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