I need to send simple mail with an attachment. Right now it sends an email but attachment is in the e-mail body like this.
--
Content-Type: text/csv;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=errors_in_address_table.csv
Content-ID: <5b0e7d6b4abff_10c12ac224c8b0d4994d@development.mail>
Current code to send email
saved_file = Rails.root.join('db', 'fix_db', 'errors_in_address_table.csv')
mailer = ActionMailer::Base.mail(from: 'no-replay@test.com', to: 'test@test.com', subject: 'Errors in database', body: '', content_type: 'multipart/mixed')
mailer.attachments['errors_in_address_table.csv'] = { mime_type: 'text/csv', content: File.read(saved_file) }
mailer.deliver
I tried to get this to work correctly for hours. Maybe some more experienced coder can help me.