jeudi 18 juin 2015

Rails 3.0: attachment in e-mail shows up as text

I am having trouble sending attachments. The body of the e-mail is always replaced by a text dump of the attachment (pdf). I can reproduce the problem in the Rails console:

m=ActionMailer::Base.mail(:to => "address@gmail.com", :subject => 'test attachment', :body => "test", :from => "address@gmail.com")
m.attachments["filename.pdf"] = {:content_type => "application/pdf", :body => File.read("/Users/folder/fietsen.pdf")}
m.deliver

It happens when I use mailtrap and when I use the Google smtp server.

Aucun commentaire:

Enregistrer un commentaire