如何将电子邮件格式化为 Gmail?

发布于 2024-11-19 08:00:17 字数 975 浏览 2 评论 0原文

我将电子邮件的正文封装在

 中。 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 中设置格式吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╰つ倒转 2024-11-26 08:00:17

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

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

<table>

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

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

等等。

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..

挽梦忆笙歌 2024-11-26 08:00:17

我认为使用
进行换行可以,但可能有更好的解决方案......

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

诠释孤独 2024-11-26 08:00:17

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

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文