1

我将电子邮件的正文包裹在<html><body><pre>. Show original in gmail 给了我我想要的电子邮件格式:

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

但实际的电子邮件显示为一行。请注意,我用来对齐的空间:和新行一样被省略了。

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 

我使用pony从 ruby​​ 发送电子邮件。

有什么建议可以根据需要在 gmail 中获取格式吗?

4

3 回答 3

3

我会建议简单地使用 HTML 表格来做到这一点。

只是为了彻底回答,代码将类似于:

<table>

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

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

ETC..

于 2011-07-12T03:26:12.917 回答
2

我认为使用<br/>换行符会起作用,但可能有更好的解决方案......

于 2011-07-12T03:11:44.483 回答
1

这是我向 gmail 发送 html 电子邮件。我想我缺少的是:html_body => body,小马设置的一部分。

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
于 2012-02-29T02:51:51.070 回答