I am successfully generating and sending an email with the following code.
class UserMailer < ActionMailer::Base
default :from => '[email protected]',
:date => Time.now
def new_user(user)
mail_subject = ['WELCOME TO ACME, INC', 'USER ACTIVATION']
@user = user
mail.attachments['File One.pdf'] = File.read(File.join(ATTACHMENT_DIR, 'shared', 'file_one.pdf'))
mail.attachments['File Two.pdf'] = File.read(File.join(ATTACHMENT_DIR, 'shared', 'file_two.pdf'))
mail.attachments['File Three.pdf'] = File.read(File.join(ATTACHMENT_DIR, 'shared', 'file_three.pdf'))
mail.attachments['File Four.pdf'] = File.read(File.join(ATTACHMENT_DIR, 'shared', 'file_four'))
mail( :to => user.address.email,
:subject => mail_subject.join(' ~ ').upcase )
end
end
However, the email contains three text documents which are identical to the content of the email body. The view I'm using for the mailer is named new_user.text.erb.
I suspect that for each pdf document I'm attaching, a plain text document is generated as well, the first being the actual email document body and the remaining three are attached along with the pdf documents.
How may I attach these pdf documents without also attaching these (repeating) text documents? Has anyone else run into this?