views:

168

answers:

1

I want to send multiple attachments but not declaring them just octet-stream doing it right now like this

newsletter.attachments.each do |file|
  contend = File.new(file.path+"/"+file.filename, "r")
    attachment "application/octet-stream" do |a|
      a.body = contend.read
      a.filename = file.filename
end unless file.blank?

since not all clients can handel that, so is there a rails plugin that selects the mime-type based on file extension, or even content?

googled alot, couldn't find what i was searching for

or am I doing this completeley wrong?

+2  A: 

Use the mime-types gem: gem install mime-types

Should be used like:

attachment MIME::Types.type_for(cv.original_filename).to_s do |a|
  a.body = cv.read
  a.filename = cv.original_filename
end
Jeroen van Dijk