Assessing why it is not working
According to SO post Invalid file name in email (ActionMailer) , it seems that ActionMailer wants to automatically extract information from files, which is not available from the console.
I noted that from the console you can use the following, albeit messy, jobs (enough for my purposes):
File.open("magical_elephant_potato.txt", 'w') {|f| f.write("Heyyyy youuu!") } m=ActionMailer::Base.mail(:to => " rainbowpony@company.com ", :from => " noreply@railsapp.com ", :subject=>"Behold my MEP attache", :content_type=>"multipart/mixed") m.attachments['magical_elephant_potato.txt']=File.read("magical_elephant_potato.txt") m.deliver FileUtils.rm('magical_elephant_potato.txt')
Given that writing and deleting files through the console works, maybe the files needed by ActionMailer can be written, used and deleted? However, we are heading for a sticky workaround. The problem is that ActionMailer will look for a suitable view for the mailer, but how can we tell ActionMailer where to search for mailer files? (As in, file name)
As for the incorrect encoding of the information, I think the problem is that it is wrapped in a "noname" file with some header information. The data is probably not corrupted since in my example I get:
-- Date: Tue, 08 Jan 2013 11:08:57 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; filename=magical_elephant_potato.txt Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=magical_elephant_potato.txt Content-ID: < 50bbfe4898ac_6d7febf6a312062@ws9.companydev.com.mail > Heyyyy youuu! ----
: when I open 'noname' with a text editor.
source share