Nazar Hussain
Nazar Hussain

Reputation: 5162

Amazon SES attachment error for ICS files

I am facing attachment error with Amazon SES service. Normal pdf or jpg files are attached properly. But when i attach a .ics file which is a calender file. I got this error.

554 Transaction failed: Illegal filename 'file_name.ics'

I am using aws-ses gem with rails 3.2.2

Is there any limitation from Amazon? And how can we request them to allow this mime type to our account?

Upvotes: 4

Views: 3247

Answers (2)

Nazar Hussain
Nazar Hussain

Reputation: 5162

The actual issue was that the email has content type multipart/mixed and the part which holds the ics file has the cotent type text/plain, According to Amazon MIME Types, text/plain must have extensions txt, diff, text. But in my case it was having .ics extension.

So i have to change the code from this.

attachments["file_name.ics"] = @model.to_ical

to this.

attachments["file_name.ics"] = {:mime_type => 'text/calendar',
                                            :content => @model.to_ical}

and it solved my problem.

Upvotes: 8

Steffen Opel
Steffen Opel

Reputation: 64761

While Amazon SES does not accept every MIME type indeed, Content Type text/calendarand Extension ics are properly supported as per their respective Appendix: MIME Types.

Without looking at their source, I suspect this to be a limitation of the aws-ses gem eventually (the list of MIME types supported by SES has grown over time) and suggest you give the official AWS SDK for Ruby (AWS Ruby Gem) a shot instead, which should nowadays provide more consistent and properly maintained development/usage experience for all already supported AWS services.

Good luck!

Upvotes: 1

Related Questions