Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 671
Nazar Hussain Avatar asked Jan 17 '23 00:01

Nazar Hussain


2 Answers

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.

like image 150
Nazar Hussain Avatar answered Jan 22 '23 01:01

Nazar Hussain


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!

like image 38
Steffen Opel Avatar answered Jan 21 '23 23:01

Steffen Opel