Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3, ActionMailer with AWS SES and attachments in Sparrow and Apple Mail
    text
    copied!<p>I am experiencing problems with ActionMailer, AWS SES and attachments (not inline) in Rails 3.2.13. When viewing the email in Gmail, it's displayed without any problems. When viewing it in Apple Mail or Sparrow, either attachment is missing and the body is displayed or vice-versa. </p> <p>The headers for the email are as follows:</p> <pre><code>Return-Path: 0000013e79305031-08aae59a-f7a0-41c9-8bd9-076c46caf100-000000@amazonses.com Date: Mon, 6 May 2013 09:33:29 +0000 From: Test Account &lt;test@test.com&gt; To: test@localhost.com Message-ID: &lt;0000013e79305031-46caf100-000000@email.amazonses.com&gt; Subject: TEST Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_518778e85f16a_56844ceff0898ed"; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SES-Outgoing: 129.255.144.108 </code></pre> <p>If the body is shown, the attachment can be found at the end of the source though:</p> <pre><code>----==_mimepart_518778e85f16a_56844ceff0898ed Date: Mon, 06 May 2013 09:33:28 +0000 Mime-Version: 1.0 Content-Type: application/pdf; charset=UTF-8; filename="Test.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Test.pdf" Content-ID: &lt;518778e829b75_56844ceff089553@ip-10-36-149-153.mail&gt; ... </code></pre> <p>I have found similar errors on Stack Overflow (<a href="https://stackoverflow.com/questions/1118592/problem-sending-multipart-mail-using-actionmailer/7177061#7177061">Problem sending multipart mail using ActionMailer</a>) but the suggested solutions did not work - especially the solution at the bottom is very interesting, as it focuses on a solution without inline attachments (<a href="https://stackoverflow.com/a/16334096/1016269">https://stackoverflow.com/a/16334096/1016269</a>). I get an error from AWS though saying that the start boundary is not set - I tried to explicitly set it, but no luck so far.</p> <p>This is the original code I use for sending the email:</p> <pre><code>def test_email attachments["Test.pdf"] = File.read(Rails.root.join("data", "test.pdf")) mail(to: recipient, subject: "Test Email") end </code></pre> <p>This is the code based on the solutions suggested in the link I posted:</p> <pre><code>def test_email mixed = mail(to: recipient, subject: "Test Email") mixed.add_part( Mail::Part.new do content_type 'multipart/alternative' # THE ODD BIT vv mixed.parts.reverse!.delete_if {|p| add_part p } end ) mixed.content_type 'multipart/mixed' mixed.header['content-type'].parameters[:boundary] = mixed.body.boundary attachments["Test.pdf"] = File.read(Rails.root.join("data", "test.pdf")) end </code></pre> <p>The response is:</p> <pre><code>AWS::SES::ResponseError: InvalidParameterValue - Missing start boundary </code></pre> <p>Any ideas what could cause this issue?</p> <p>Thanks a lot</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload