发送纯文本/文本电子邮件时发送Sendgrid GEM错误

时间:2015-11-29 01:12:28

标签: ruby-on-rails ruby email sendgrid

我想通过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>{&quot;versao&quot;:&quot;cee'd SW &ndash; 1.6 CRDi ISG EX&quot;,&quot;concessionario&quot;:&quot;Sotabi&quot;,&quot;extraEmail&quot;:&quot;gerencia@sotabi.p&quot;,&quot;nome&quot;:&quot;Miguel Rebola&quot;,&quot;email&quot;:&quot;miguelrebola21@gmail.com&quot;,&quot;telefone&quot;:&quot;968823502&quot;,&quot;comentarios&quot;:&quot;fdfd&quot;,&quot;autorizo&quot;:&quot;yes&quot;}</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>

我只需要发送普通/文本。有什么想法??

2 个答案:

答案 0 :(得分:0)

需要改变Sendrigd网站上的诽谤。

答案 1 :(得分:0)

转到设置https://app.sendgrid.com/settings/mail_settings

找到Plain Content参数并将其打开。