【发布时间】:2016-03-02 21:22:59
【问题描述】:
我正在尝试通过 sendgrid gem 发送一封电子邮件以获取 ruby on rails。 这是我的邮件代码:
def send_form(params)
@params=params
mail( :to => 'my_email',
:subject => 'my_subject',:content_type => "text/plain")
end
它正在加载我的视图 send_form.json.erb 并且在视图中有这样的:
<%= raw @params.to_json %>
现在,这里的问题是来自电子邮件的源代码有 2 封电子邮件(?),一封是纯文本的,另一封是 HTML 的。
This is a multi-part message in MIME format...
------------=_1448758618-20748-809
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
{"versao":"cee'd SW - 1.6 CRDi ISG EX","concessionario":"Sotabi","extraEmail":"gerencia@sotabi.p","nome":"Miguel Rebola","email":"miguelrebola21@gmail.com","telefone":"968823502","comentarios":"fdfd","autorizo":"yes"}
------------=_1448758618-20748-809
Content-Type: text/html; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
<html><body>
<p>{"versao":"cee'd SW – 1.6 CRDi ISG EX","concessionario":"Sotabi","extraEmail":"gerencia@sotabi.p","nome":"Miguel Rebola","email":"miguelrebola21@gmail.com","telefone":"968823502","comentarios":"fdfd","autorizo":"yes"}</p>
<img src="https://u1373375.ct.sendgrid.net/wf/open?upn=u0x3fSBqEx-2Fl-2BmgujqmE8BQomXBLbogF-2Bc6F-2BtlRZ6DF0HBXi526k5pl8ZUC-2FxtIp9ic36mMF2aQ4d6eJ5Lqq9panqdI3Ye7hmz4ajbhDO44ePVyM2SMDDBBWWMpJ5l50gYvbwVmo7S80MmO-2BlSAaFwiQpqgTXdMFRmz0vHxy-2BdXYgxbqCs5K3msoeQ4SQS-2BZqoqDpo2wVLTeQrEbKzxE2cQn1u-2FORF6fYLTNqw560g-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>
我只需要发送纯文本/文本。有什么想法吗??
【问题讨论】:
-
这实际上是 HTML 电子邮件的默认格式,它们通常包含用于缺乏 HTML 支持的旧电子邮件客户端的纯文本部分。至于自动转换,也许是这个support.sendgrid.com/hc/en-us/articles/…?另外,您是否尝试过将
:html设置为空字符串并仅使用:text?
标签: ruby-on-rails ruby email sendgrid