I have a email reminder sender based on actionmailer. It sets mail subject to "[UPC ügyfélszolgálat] emlékeztető" (in English: customer reminder). Every time I got mail from my app the raw line of Subject looked like this: Subject: =?utf-8?Q? =5bUPC_=c3=bcgyf=c3=a9lszolg=c3=a1lat=5d_eml=c3=a9keztet=c5=91? After upgrading to the latest rails subject line turned into complete mess. Now the line above shows this: Subject: =??Q? =5bUPC_=c3=bcgyf=c3=a9lszolg=c3=a1lat=5d_eml=c3=a9keztet=c5=91? You can easily notice that ''utf-8'' disappeared. I haven''t changed the email sender part of my applications since upgrade. Gábor "értelmező kéziszótár: rekurzió --> lásd: rekurzió" _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 2005.10.29., at 16:24, Gábor SEBESTYÉN wrote:> You can easily notice that ''utf-8'' disappeareI found the answer. Since actiionmailer-1.1.1 a new line added to ActionMailer::Base.create! method at 289: .... unless @parts.empty? @content_type = "multipart/alternative" here-> @charset = nil @parts = sort_parts(@parts, @implicit_parts_order) end .... This completely disables quote_any_if_necessary(charset, subject) command in create_mail() therefore Subject: line will be wrong. Why charset is nilled? Is it a bug or feature?? I removed that line and my mailer works well again. Gábor "Never trust a computer you can''t throw out a window." - Steve Wozniak
On Oct 30, 2005, at 5:53 AM, Gábor SEBESTYÉN wrote:> On 2005.10.29., at 16:24, Gábor SEBESTYÉN wrote: > >> You can easily notice that ''utf-8'' disappeare >> > > I found the answer. Since actiionmailer-1.1.1 a new line added to > ActionMailer::Base.create! method at 289: > > .... > unless @parts.empty? > @content_type = "multipart/alternative" > here-> @charset = nil > @parts = sort_parts(@parts, @implicit_parts_order) > end > .... > > This completely disables quote_any_if_necessary(charset, subject) > command in create_mail() therefore Subject: line will be wrong. > Why charset is nilled? Is it a bug or feature?? > I removed that line and my mailer works well again.Gábor, Could you please file a ticket at dev.rubyonrails.com for this? It is a valid bug, but I don''t have time to hack on it right now and I don''t want it to fall through the cracks. Just assign it to jamis-uHoyYlH2B+HqLeI9t+lItQ@public.gmane.org The @charset = nil line was added in changeset 2091 (http:// dev.rubyonrails.com/changeset/2091) to work around a problem with AOL mail clients. However, the unfortunate side-effect of this is that subject lines (and headers in general) are no longer encoded correctly. What is needed is a way for the top-level part to have a blank charset in the header, and yet still have the header lines encoded in the given charset, as necessary. So, anyway, please file this as a bug. And if you (or anyone else) would like to try their hand at a patch for this (with a unit test), that''d be wonderful. Otherwise, I''ll try and tackle it as soon as I am able. - Jamis
On 10/30/05, Jamis Buck <jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org> wrote:> correctly. What is needed is a way for the top-level part to have a > blank charset in the header, and yet still have the header lines > encoded in the given charset, as necessary.Even if I can retained the subject quoting, and removed the "charset=" from content-type .. it still wouldn''t render the encoded character in subject properly. e.g. For a subject "implicitly''s multipart example", ActionMailer will generate: Subject: =?WINDOWS-1252?Q?implicitly=e2=80=99s_multipart_example?Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=mimepart_436d893b875b2_2701..fdbe83ba44ef This doesn''t display the subject properly on my mail client (gmail). But if I manually force the subject to become encoded as such (i took hint from how gmail encodes), it works: Subject: =?WINDOWS-1252?Q?implicitly=92s_multipart_example?Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=mimepart_436d8c0f177f3_27bc..fdbe5e3a4544 Looking at what other mail clients send out<http://guides.co.il/wiki/index.php/%D7%93%D7%95%D7%92%D7%9E%D7%90%D7%95%D7%AA_%D7%A9%D7%9C_%D7%94%D7%92%D7%93%D7%A8%D7%95%D7%AA_%D7%93%D7%95%D7%90%D7%A8_%D7%A2%D7%91%D7%A8%D7%99_%D7%A9%D7%92%D7%95%D7%99%D7%95%D7%AA>, "multipart/alternative;" does seem to not come accompanied by "charset=..." So.. I dunno, perhaps the error is in the quoting.rb ? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Nov 5, 2005, at 10:01 PM, choonkeat wrote:> On 10/30/05, Jamis Buck <jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org > wrote: > correctly. What is needed is a way for the top-level part to have a > blank charset in the header, and yet still have the header lines > encoded in the given charset, as necessary. > > Even if I can retained the subject quoting, and removed the > "charset=" from content-type .. it still wouldn''t render the > encoded character in subject properly. > > e.g. For a subject "implicitly''s multipart example", > > ActionMailer will generate: > Subject: =?WINDOWS-1252?Q?implicitly=e2=80=99s_multipart_example?> Mime-Version: 1.0 > Content-Type: multipart/alternative; > boundary=mimepart_436d893b875b2_2701..fdbe83ba44ef > > This doesn''t display the subject properly on my mail client > (gmail). But if I manually force the subject to become encoded as > such (i took hint from how gmail encodes), it works: > Subject: =?WINDOWS-1252?Q?implicitly=92s_multipart_example?> Mime-Version: 1.0 > Content-Type: multipart/alternative; > boundary=mimepart_436d8c0f177f3_27bc..fdbe5e3a4544 > > Looking at what other mail clients send out, "multipart/ > alternative;" does seem to not come accompanied by "charset=..." > > So.. I dunno, perhaps the error is in the quoting.rb ?I''ve added a test case that shows that ActionMailer is encoding the subject even for multipart messages. However, I can''t seem to create a failing test case. I''m wondering if you''re encountering a problem where your editor is inserting the text in utf-8, but you are specifying a different charset, which is causing the charset conversion to corrupt the original text? Something like this: 1. You edit your source code and save it using utf-8, but you specify a non-utf8 charset: ... subject "안녕하세요" # utf-8 text charset "WINDOWS-1252" # non-utf-8 charset ... 2. ActionMailer executes and builds a new email. However, AM does not do any charset conversions when creating emails (it doesn''t know what the original charset is). Thus, it quotes the subject line, specifying the charset you gave, but using the utf-8 string you specified. 3. When the recipient receives your email, their client will try to interpret the subject line as WINDOWS-1252 text, even though it is utf-8 text. If the above scenario describes what is happening, let me know. In this case, you can work around it by explicitly converting your subject text to the WINDOWS-1252 charset: subject(Iconv.iconv("WINDOWS-1252", "utf-8", "안녕하세요")) charset "WINDOWS-1252" - Jamis
On 11/6/05, Jamis Buck <jamis@37signals.com> wrote:> I'm wondering if you're encountering a problem where your editor is > inserting the text in utf-8, but you are specifying a different > charset, which is causing the charset conversion to corrupt the > original text? Something like this:Hello Jamis, I do experience the same problem. My rails app uses Unicode (http headers are correct, so does the rendering) then forms too. Files are all saved in unicode with TextMate.app editor. However, emails sent by ActionMailer have the following headers and are misinterpreted by Mail.app (which read them as latin-1): Subject: =?utf-8?Q?=5bCONTACT=5d_Message_laiss=c3?Content-Type: text/plain; charset=utf-8 This is terrible :( _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/9/05, Jérôme L <eugenol@gmail.com> wrote:> However, emails sent by ActionMailer have the following headers and > are misinterpreted by Mail.app (which read them as latin-1):> Subject: =?utf-8?Q?=5bCONTACT=5d_Message_laiss=c3?> Content-Type: text/plain; charset=utf-8Sorry Jamis, email body is fine and well interpreted as unicode. Then the problem is only at the "Subject:" header... _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Nov 8, 2005, at 6:34 PM, Jérôme L wrote:> On 11/9/05, Jérôme L <eugenol-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> However, emails sent by ActionMailer have the following headers and >> are misinterpreted by Mail.app (which read them as latin-1): > >> Subject: =?utf-8?Q?=5bCONTACT=5d_Message_laiss=c3?>> Content-Type: text/plain; charset=utf-8 > > Sorry Jamis, email body is fine and well interpreted as unicode. Then > the problem is only at the "Subject:" header...If you can send me a failing test case, that will help immensely. As it is, I cannot duplicate the problem. :( - Jamis