1

I wrapped the email's body in <html><body><pre>. Show original in gmail gives me actually how I want the email to be formatted:

Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit


Ant run name    : Basics of Edumate
Overall result  : pass

Ant run took: 4 minutes 15 seconds

--------------------------
Details for all test suits
--------------------------

login           : Pass
AddCycleTemplate: Pass
AddCycleTemplate: Pass
AddAcademicYear : Pass
AddAcademicYear : Pass

But the actual email is displayed as one line. Note that space that I use to align : is somehow omitted as well as new lines.

Ant run name : Basics of Edumate Overall result : pass Ant run took: 4 minutes 15 seconds -------------------------- Details for all test suits -------------------------- login : Pass AddCycleTemplate: Pass AddCycleTemplate: Pass AddAcademicYear : Pass AddAcademicYear : Pass 

I send the email from ruby using pony.

Any suggestions how to get the formatting inside gmail as desired?

Radek
  • 13,813
  • 52
  • 161
  • 255

3 Answers3

3

I would recommend to simply use an HTML table to do that.

Just for the sake of answering thoroughly, the code would be something like:

<table>

<tr>
<td>Mime-Version:</td>
<td>1.0</td>
</tr>

<tr>
<td>Content-Type:</td>
<td>text/html;</td>
</tr>
...
</table>

etc..

Gustav
  • 31
  • 4
  • The thing with spaces is they will not display the same depending on the font settings of users in gmail. Users using monospace fonts (such as with the terminal theme under gmail) will have the layout all broken. – Gustav Jul 12 '11 at 03:27
  • so is there any way to have the email aligned nicely? – Radek Jul 12 '11 at 23:43
2

I think using <br/> for line breaks would work, but there's probably a better solution...

Jomasi
  • 323
  • 1
  • 4
  • 14
1

This the was I send html email to gmail. I guess what I was missing was :html_body => body, part of pony's settings.

def email_it(body, subject,to,from)
  $smtp = 'mail.com.au'
  $smtp_port = 25
     Pony.mail(
        :to => to, 
        :from => from,
        :subject => subject, 
        :body => Nokogiri::HTML(body).text, 
                    :html_body =>  body,
        :via => :smtp, 
        :via_options => {
                :address     => $smtp,
                :port     => $smtp_port,
                :enable_starttls_auto => false
        }
    )
end
Radek
  • 13,813
  • 52
  • 161
  • 255