我无法发送带有文本附件的电子邮件(没有附件,一切都很好)。我正在使用 actionmailer 3.2.11 并尝试通过 Amazon SES 发送电子邮件。在我看来,亚马逊 snmp 服务器在我生成的电子邮件方面存在问题。生成电子邮件的代码如下所示:
class ServiceMailer < ActionMailer::Base
default from: "noreply@dungeonpilot.com"
def server_crashed log_file_names
attachments[ 'foo.txt' ] = 'Hallo'
mail to: 'Txxx@xxzki.de', subject: '[dungeonpilot] Server Crashed'
end
end
发送邮件时的错误消息:Net::SMTPFatalError: 554 Transaction failed: Missing start boundary
.
生成的邮件是这样的:
Date: Fri, 08 Feb 2013 10:11:09 +0000
From: noreply@dungeonpilot.com
To: Txxx@xxxzki.de
Message-ID: <5114cf3dc4886_701165e7f848869@ip-10-62-103-46.mail>
Subject: [dungeonpilot] Server Crashed
Mime-Version: 1.0
Content-Type: multipart/mixed;
charset=UTF-8
Content-Transfer-Encoding: 7bit
--
Date: Fri, 08 Feb 2013 10:11:09 +0000
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=foo.txt
filename: foo.txt
Content-ID: <5114cf3d55085_701165e7f8487cc@ip-10-62-103-46.mail>
Hallo
----
将此作为测试邮件传递给 SES,也会导致“缺少开始边界”。所以我认为交付的内容一定有问题。
在views 文件夹中,只有一个.txt.erb 模板。我添加了一个 .html.erb 模板,现在boundary="
邮件部分之间有一个 -header 和边界:
Date: Fri, 08 Feb 2013 10:26:57 +0000
From: noreply@dungeonpilot.com
To: Torsten@Robitzki.de
Message-ID: <5114d2f1b8175_702812508041181@ip-10-62-103-46.mail>
Subject: [dungeonpilot] Server Crashed
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="--==_mimepart_5114d2f18f621_7028125080411632";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_5114d2f18f621_7028125080411632
Date: Fri, 08 Feb 2013 10:26:57 +0000
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=foo.txt
filename: foo.txt
Content-ID: <5114d2f0ee34b_7028125080411545@ip-10-62-103-46.mail>
Hallo
----==_mimepart_5114d2f18f621_7028125080411632
Date: Fri, 08 Feb 2013 10:26:57 +0000
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <5114d2f19ce45_7028125080411785@ip-10-62-103-46.mail>
----==_mimepart_5114d2f18f621_7028125080411632--
看起来像 ActionMailer 中的错误?