开发者

Ruby: Mail gem add \r\n after 60 chars in mail

开发者 https://www.devze.com 2023-03-19 10:09 出处:网络
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.

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.

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

Original string (smime0): https://gist.github.com/1d2c84cc2e255be010a6

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

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 ho开发者_Go百科w to turn off it, but was failed.

May be there is some other workaround for this point.

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?


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

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).

Possible workarounds:

  • Fix the Mail gem to prevent it from adding a Content-ID
  • Add a Content-ID before signing, because Mail will keep it if it's present
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号