Forum: Ruby on Rails Multipart email, how to bypass the bug?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
04e1b6bf268d6110f4ca25201186f726?d=identicon&s=25 Xdmx Xdmx (xdmx)
on 2008-10-12 18:31
Hi, i've to send a mail in the multipart format, but it became a mess
because of a 2 years old bug. It change stuff like style="... to
style=3D" so the clients doesn't render the mail good.
I've open a bug report at
http://rails.lighthouseapp.com/projects/8994-ruby-...

But how can it be fixed temporally until the fix enter the rails source?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-12 19:12
(Received via mailing list)
On 12 Oct 2008, at 17:31, Xdmx Xdmx wrote:

>
> Hi, i've to send a mail in the multipart format, but it became a mess
> because of a 2 years old bug. It change stuff like style="... to
> style=3D" so the clients doesn't render the mail good.
> I've open a bug report at
> 
http://rails.lighthouseapp.com/projects/8994-ruby-...
>
I've got multipart html emails that work just fine. What are you doing
in your mailer ?

Fred
04e1b6bf268d6110f4ca25201186f726?d=identicon&s=25 Xdmx Xdmx (xdmx)
on 2008-10-12 21:33
Frederick Cheung wrote:
> I've got multipart html emails that work just fine. What are you doing
> in your mailer ?
>
> Fred


Nothing special. This is the code:

*** notifications.rb:

  def alert
    @sent_on      = Time.now
    @from         = 'test@test.com'
    @recipients   = 'test@test.com'
    @subject      = 'test'
    @body         = {:reqst => '<div style="color:red">test</div>'}
  end

*** alert.text.plain.erb:

<%= @reqst %>

*** alert.text.html.erb:

<%= @reqst %>

*** console:

>> x = Notifications.create_alert
=> #<TMail::Mail port=#<TMail::StringPort:id=0x..fdb902954>
bodyport=#<TMail::StringPort:id=0x..fdb8fff88>>
>> x.encoded
=> "Date: Sun, 12 Oct 2008 21:30:13 +0200\r\nFrom: test@test.com\r\nTo:
test@test.com\r\nSubject: test\r\nMime-Version: 1.0\r\nContent-Type:
multipart/alternative;
boundary=mimepart_48f250492c08b_2098..fdbfb1b7e3e0\r\n\r\n\r\n--mimepart_48f250492c08b_2098..fdbfb1b7e3e0\r\nContent-Type:
text/plain; charset=utf-8\r\nContent-Transfer-Encoding:
Quoted-printable\r\nContent-Disposition: inline\r\n\r\n<div
style=3D\"color:red\">test</div>=\n\r\n--mimepart_48f250492c08b_2098..fdbfb1b7e3e0\r\nContent-Type:
text/html; charset=utf-8\r\nContent-Transfer-Encoding:
Quoted-printable\r\nContent-Disposition: inline\r\n\r\n<div
style=3D\"color:red\">test</div>=\n\r\n--mimepart_48f250492c08b_2098..fdbfb1b7e3e0--\r\n"




As you can see is: <div style=3D\"color:red\">test</div>
It adds that 3D (ascii: '=') and that cause the wrong rendering on a lot
of email clients :(
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-12 22:37
(Received via mailing list)
On 12 Oct 2008, at 20:33, Xdmx Xdmx wrote:
>
>
>
>
> As you can see is: <div style=3D\"color:red\">test</div>
> It adds that 3D (ascii: '=') and that cause the wrong rendering on a
> lot
> of email clients :(

Isn't that normal? Give that the encoding is quoted printable, = signs
have to be escaped. It does that with the mails I send and it does not
cause a problem.

My emails do however contain a full html document (ie with a doctype,
a top level html tag, a head tag, a body tag etc... rather than just a
frament.

Fred
04e1b6bf268d6110f4ca25201186f726?d=identicon&s=25 Xdmx Xdmx (xdmx)
on 2008-10-12 22:54
Frederick Cheung wrote:
> On 12 Oct 2008, at 20:33, Xdmx Xdmx wrote:
>
> Isn't that normal? Give that the encoding is quoted printable, = signs
> have to be escaped. It does that with the mails I send and it does not
> cause a problem.
>
> My emails do however contain a full html document (ie with a doctype,
> a top level html tag, a head tag, a body tag etc... rather than just a
> frament.
>
> Fred

I don't know if it normal, but it doesn't seems to me :)
Actually i put only the html between body and /body excluded. I don't
know how good is to put also the html and head stuff. I think it'd add
some points to antispam software like spamassassin, and in the webmail
there would be 2 <html> tags.
Btw i've tried to add the html and head tags, and at least on my webmail
now it recognize the links.

But i don't know how right is to set the encode in the html/head, as
there is the value on the mail which tell the encode: Content-Type:
text/html; charset=utf-8
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-12 23:10
(Received via mailing list)
On Oct 12, 9:54 pm, Xdmx Xdmx <rails-mailing-l...@andreas-s.net>
wrote:
> Frederick Cheung wrote:
> > On 12 Oct 2008, at 20:33, Xdmx Xdmx wrote:
>
>
> I don't know if it normal, but it doesn't seems to me :)

= is a special character when using quoted printable. That's just the
way it is (much like % is special in urls)

> Actually i put only the html between body and /body excluded. I don't
> know how good is to put also the html and head stuff. I think it'd add
> some points to antispam software like spamassassin, and in the webmail
> there would be 2 <html> tags.

As far as I know webmail clients are built to deal with this sort of
thing. Works for me anyway.

Fred
This topic is locked and can not be replied to.