Search code examples
actionmaileramazon-ses

"Missing start boundary" when sending Emails with Text attachment


I have trouble sending Emails with text attachments (without attachment, everything is fine). I'm using actionmailer 3.2.11 and try to send Emails over Amazon SES. To me it looks like, that the amazon snmp server has a problem with the emails I produce. The code to produce the email looks like this:

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

The error message, when sending mails: Net::SMTPFatalError: 554 Transaction failed: Missing start boundary.

The resulting Mail is this:

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

----

Delivering this to SES as a Test Mail, results too in "Missing start boundary". So I think there must be something wrong with the delivered content.

In the views folder, there was just one .txt.erb template. I've added a .html.erb template and now there is a boundary="-header and boundaries between the mail parts:

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

Looks like a bug in ActionMailer?


Solution

  • My fault, I've named the template with a txt extension, not with a text extension.

    The next version of actionmailer will throw an exception, in this case.