# Multipart email, how to bypass the bug?

**URL:** <https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756>\
**Category:** Rails\
**Created:** [October 12, 2008, 6:31pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756 "2008-10-12T18:31:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [October 12, 2008, 6:31pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756/1 "2008-10-12T18:31:44Z")

</div>

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-on-rails/tickets/1204-email-multipart-2-years-old-bug](http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1204-email-multipart-2-years-old-bug)

But how can it be fixed temporally until the fix enter the rails source?

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [October 12, 2008, 7:12pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756/2 "2008-10-12T19:12:38Z")

</div>

On 12 Oct 2008, at 17:31, Xdmx X. 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  
> [#1204 Email multipart 2 years old bug - Ruby on Rails - rails](http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1204-email-multipart-2-years-old-bug)

I’ve got multipart html emails that work just fine. What are you doing  
in your mailer ?

Fred

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [October 12, 2008, 9:33pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756/3 "2008-10-12T21:33:22Z")

</div>

Frederick C. 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 = ‘removed\_email\_address@domain.invalid’  
@recipients = ‘removed\_email\_address@domain.invalid’  
@subject = ‘test’  
@body = {:reqst =\> ‘

test
’}  
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: removed\_email\_address@domain.invalid\r\nTo:  
> > removed\_email\_address@domain.invalid\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=\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=\n\r\n–mimepart\_48f250492c08b\_2098…fdbfb1b7e3e0–\r\n"

As you can see is: \<div style=3D"color:red"\>test  
It adds that 3D (ascii: ‘=’) and that cause the wrong rendering on a lot  
of email clients ☹

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [October 12, 2008, 10:54pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756/4 "2008-10-12T22:54:20Z")

</div>

Frederick C. wrote:

> On 12 Oct 2008, at 20:33, Xdmx X. 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 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

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [October 12, 2008, 10:37pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756/5 "2008-10-12T22:37:39Z")

</div>

On 12 Oct 2008, at 20:33, Xdmx X. wrote:

> As you can see is: \<div style=3D"color:red"\>test  
> 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

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [October 12, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/multipart-email-how-to-bypass-the-bug/150756/6 "2008-10-12T23:10:27Z")

</div>

On Oct 12, 9:54 pm, Xdmx X. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Frederick C. wrote:
> 
> > On 12 Oct 2008, at 20:33, Xdmx X. 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 tags.

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

Fred
