body of email not displaying with attachments in rails2.3.5

4 views
Skip to first unread message

pradeep...@gmail.com

unread,
Sep 29, 2013, 3:13:58 AM9/29/13
to rubyonra...@googlegroups.com
I am sending an email through my application to other user's gmail id. I am receiving email and it works fine without attachment. But when I attach a file, the mail which users receive contain subject and attachments only. The body part is not displaying in the mail. In the controller I am passing everything as params to reminder_email method. I am using rails2.3.5..This is how I have implemented in my mailer.rb file. Please help.

    class ReminderMailer < ActionMailer::Base
   
      def reminder_email(sender,recipients, subject, message,attachments)
        recipient_emails = (recipients.class == String) ? recipients.gsub(' ','').split(',').compact : recipients.compact
        setup_reminder_email(sender, recipient_emails, subject, message,attachments)
      end
   
      protected
      def setup_reminder_email(sender, emails, subject, message,files)
        @from = sender
        @recipients = emails
        @subject = subject
        @sent_on = Time.now
        @body['message'] = message
        #content_type =  "multipart/alternative"
         files.each do |file|
          attachment "application/octet-stream" do |a|
          a.body = file.read
          a.filename = file.original_filename
        end unless file.blank?
        end
      end
    end
Reply all
Reply to author
Forward
0 new messages