I am getting html output in my email body with spurious characters that cannot be rendered, so that my links are not handled properly. What am I not getting here? My email body contains: -----------------clip------------- <A href=mailto:"<%=h(''support-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'')%>? Support">Support</A><br/> with any issues. Please include your order number... -----------------clip------------- I''m getting ''=3d'' for all ''='' so that the <A href=... becomes <A href=3d... which is garbage. I have tried using all possible combinations of h() and mailto function: those don''t fix it. That is NOT the problem. This is my method in order_mailer: def price(order) @subject = "Order Email @recipients = order.email @from = ''support-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'' @sent_on = Time.now @body["order"] = order part :content_type => "text/plain", :body => render_message("price_text_html", :order => order) end I tried content type text/html first, text/plain also does not work. I can''t use the utf code for ''='', it isn''t understood properly. By the way, 3d is the hex unicode for ''=''. What''s up?? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Kent Sibilev
2008-Nov-30 06:23 UTC
Re: ActionMailer weirdness: bad html ''=3d'' for all ''=''
On Sun, Nov 30, 2008 at 12:46 AM, minka <beta-5eibb9424EpWk0Htik3J/w@public.gmane.org> wrote:> > I am getting html output in my email body with spurious characters > that cannot be rendered, so that my links are not handled properly. > What am I not getting here? > > My email body contains: > -----------------clip------------- > <A href=mailto:"<%=h(''support-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'')%>? > Support">Support</A><br/> > > with any issues. Please include your order number... > -----------------clip------------- > I''m getting ''=3d'' for all ''='' so that the <A href=... becomes <A > href=3d... which is garbage. > > I have tried using all possible combinations of h() and mailto > function: those don''t fix it. > That is NOT the problem. > > This is my method in order_mailer: > def price(order) > @subject = "Order Email > @recipients = order.email > @from = ''support-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'' > @sent_on = Time.now > @body["order"] = order > > part :content_type => "text/plain", > :body => render_message("price_text_html", :order => order) > > end > > I tried content type text/html first, text/plain also does not work. > > I can''t use the utf code for ''='', it isn''t understood properly. > > By the way, 3d is the hex unicode for ''=''. > > What''s up?? >SMTP protocol uses 7bit ASCII characters, so your emails must be properly encoded. You can read more about this at http://en.wikipedia.org/wiki/MIME. BTW, you can use tmail gem in order to decode your emails. I suspect something like this should work: require ''rubygems'' require ''tmail'' email = TMail::Mail.parse(email_text) puts email.body -- Kent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I tried TMail parse and I tried manually changing unicode to 7bit ascii, nothing worked. so finally I did it brute force. In my controller @order = Order.find(params[:id]) email = TMail::Mail.new email = OrderMailer.create_price(@order) # BRUTE FORCE, nothing else worked! # contaminated html in my emails!! # All ''='' became ''=3D'' # NOTE TMail::Mail.parse() did not fix this. email_fix = email.encoded.gsub(/[3][D]/,'''') # replace ''3D'' with empty string in email WORKED email = TMail::Mail.parse(email_fix) OrderMailer.deliver(email) On Nov 29, 10:23 pm, "Kent Sibilev" <ksr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Nov 30, 2008 at 12:46 AM, minka <b...-5eibb9424EpWk0Htik3J/w@public.gmane.org> wrote: > > > I am getting html output in my email body with spurious characters > > that cannot be rendered, so that my links are not handled properly. > > What am I not getting here? > > > My email body contains: > > -----------------clip------------- > > <A href=mailto:"<%=h(''supp...-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'')%>? > > Support">Support</A><br/> > > > with any issues. Please include your order number... > > -----------------clip------------- > > I''m getting ''=3d'' for all ''='' so that the <A href=... becomes <A > > href=3d... which is garbage. > > > I have tried using all possible combinations of h() and mailto > > function: those don''t fix it. > > That is NOT the problem. > > > This is my method in order_mailer: > > def price(order) > > @subject = "Order Email > > @recipients = order.email > > @from = ''supp...-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'' > > @sent_on = Time.now > > @body["order"] = order > > > part :content_type => "text/plain", > > :body => render_message("price_text_html", :order => order) > > > end > > > I tried content type text/html first, text/plain also does not work. > > > I can''t use the utf code for ''='', it isn''t understood properly. > > > By the way, 3d is the hex unicode for ''=''. > > > What''s up?? > > SMTP protocol uses 7bit ASCII characters, so your emails must be > properly encoded. You can read more about this athttp://en.wikipedia.org/wiki/MIME. > > BTW, you can use tmail gem in order to decode your emails. I suspect > something like this should work: > > require ''rubygems'' > require ''tmail'' > > email = TMail::Mail.parse(email_text) > puts email.body > > -- > Kent--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-01 22:40 UTC
Re: ActionMailer weirdness: bad html ''=3d'' for all ''=''
On Dec 1, 10:30 pm, minka <b...-5eibb9424EpWk0Htik3J/w@public.gmane.org> wrote:> I tried TMail parse and I tried manually changing unicode to 7bit > ascii, > nothing worked. so finally I did it brute force. In my controller >The email was encoded with quoted-printable. In that encoding = is a special character so is escaped with =3D. You can set the transfer encoding to something other than quoted- printable (eg not encode at all), but if you don''t encode at all the mail could get garbled when passing through some mail servers. There''s an example in the docs of how to set the transfer encoding to base64, you could instead just set it to ''identity'' (actually actionmailer won''t do any encoding if that setting is not either quoted-printable of base64 but you might as well pick a sensible name) If your email is indeed html, why are you setting the content type to text/plain ? Fred> @order = Order.find(params[:id]) > email = TMail::Mail.new > email = OrderMailer.create_price(@order) > # BRUTE FORCE, nothing else worked! > # contaminated html in my emails!! > # All ''='' became ''=3D'' > # NOTE TMail::Mail.parse() did not fix this. > email_fix = email.encoded.gsub(/[3][D]/,'''') # replace ''3D'' with > empty string in email WORKED > email = TMail::Mail.parse(email_fix) > OrderMailer.deliver(email) > > On Nov 29, 10:23 pm, "Kent Sibilev" <ksr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Sun, Nov 30, 2008 at 12:46 AM, minka <b...-5eibb9424EpWk0Htik3J/w@public.gmane.org> wrote: > > > > I am getting html output in my email body with spurious characters > > > that cannot be rendered, so that my links are not handled properly. > > > What am I not getting here? > > > > My email body contains: > > > -----------------clip------------- > > > <A href=mailto:"<%=h(''supp...-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'')%>? > > > Support">Support</A><br/> > > > > with any issues. Please include your order number... > > > -----------------clip------------- > > > I''m getting ''=3d'' for all ''='' so that the <A href=... becomes <A > > > href=3d... which is garbage. > > > > I have tried using all possible combinations of h() and mailto > > > function: those don''t fix it. > > > That is NOT the problem. > > > > This is my method in order_mailer: > > > def price(order) > > > @subject = "Order Email > > > @recipients = order.email > > > @from = ''supp...-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'' > > > @sent_on = Time.now > > > @body["order"] = order > > > > part :content_type => "text/plain", > > > :body => render_message("price_text_html", :order => order) > > > > end > > > > I tried content type text/html first, text/plain also does not work. > > > > I can''t use the utf code for ''='', it isn''t understood properly. > > > > By the way, 3d is the hex unicode for ''=''. > > > > What''s up?? > > > SMTP protocol uses 7bit ASCII characters, so your emails must be > > properly encoded. You can read more about this athttp://en.wikipedia.org/wiki/MIME. > > > BTW, you can use tmail gem in order to decode your emails. I suspect > > something like this should work: > > > require ''rubygems'' > > require ''tmail'' > > > email = TMail::Mail.parse(email_text) > > puts email.body > > > -- > > Kent--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
the content type is text/html. Where and how should I specify encoding? Is it this: mail = TMail::Mail.new mail.transfer_encoding = "something" What should "something" be? this email is plain, vanilla, simple, nothing fancy, no special characters, etc. I just want something plain, simple etc that WORKS on ALL mail servers. thanks much! minka On Dec 1, 2:40 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 1, 10:30 pm, minka <b...-5eibb9424EpWk0Htik3J/w@public.gmane.org> wrote:> I tried TMail parse and I tried manually changing unicode to 7bit > > ascii, > > nothing worked. so finally I did it brute force. In my controller > > The email was encoded with quoted-printable. In that encoding = is a > special character so is escaped with =3D. > > You can set the transfer encoding to something other than quoted- > printable (eg not encode at all), but if you don''t encode at all the > mail could get garbled when passing through some mail servers. There''s > an example in the docs of how to set the transfer encoding to base64, > you could instead just set it to ''identity'' (actually actionmailer > won''t do any encoding if that setting is not either quoted-printable > of base64 but you might as well pick a sensible name) > > If your email is indeed html, why are you setting the content type to > text/plain ? > > Fred > > > @order = Order.find(params[:id]) > > email = TMail::Mail.new > > email = OrderMailer.create_price(@order) > > # BRUTE FORCE, nothing else worked! > > # contaminated html in my emails!! > > # All ''='' became ''=3D'' > > # NOTE TMail::Mail.parse() did not fix this. > > email_fix = email.encoded.gsub(/[3][D]/,'''') # replace ''3D'' with > > empty string in email WORKED > > email = TMail::Mail.parse(email_fix) > > OrderMailer.deliver(email) > > > On Nov 29, 10:23 pm, "Kent Sibilev" <ksr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Sun, Nov 30, 2008 at 12:46 AM, minka <b...-5eibb9424EpWk0Htik3J/w@public.gmane.org> wrote: > > > > > I am getting html output in my email body with spurious characters > > > > that cannot be rendered, so that my links are not handled properly. > > > > What am I not getting here? > > > > > My email body contains: > > > > -----------------clip------------- > > > > <A href=mailto:"<%=h(''supp...-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'')%>? > > > > Support">Support</A><br/> > > > > > with any issues. Please include your order number... > > > > -----------------clip------------- > > > > I''m getting ''=3d'' for all ''='' so that the <A href=... becomes <A > > > > href=3d... which is garbage. > > > > > I have tried using all possible combinations of h() and mailto > > > > function: those don''t fix it. > > > > That is NOT the problem. > > > > > This is my method in order_mailer: > > > > def price(order) > > > > @subject = "Order Email > > > > @recipients = order.email > > > > @from = ''supp...-t1rxLZ7CIXjQT0dZR+AlfA@public.gmane.org'' > > > > @sent_on = Time.now > > > > @body["order"] = order > > > > > part :content_type => "text/plain", > > > > :body => render_message("price_text_html", :order => order) > > > > > end > > > > > I tried content type text/html first, text/plain also does not work. > > > > > I can''t use the utf code for ''='', it isn''t understood properly. > > > > > By the way, 3d is the hex unicode for ''=''. > > > > > What''s up?? > > > > SMTP protocol uses 7bit ASCII characters, so your emails must be > > > properly encoded. You can read more about this athttp://en.wikipedia.org/wiki/MIME. > > > > BTW, you can use tmail gem in order to decode your emails. I suspect > > > something like this should work: > > > > require ''rubygems'' > > > require ''tmail'' > > > > email = TMail::Mail.parse(email_text) > > > puts email.body > > > > -- > > > Kent--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---