I want to be able to attach a file that I generate (on the fly, I dont want to save the file on my server) and send it out via email.
I have the text all done, but I'm lost on how to attach the file to the email using sendmail
Thank you
The simplest way to display Outlook's search tools is to click in the Search Current Mailbox box at the top of the message list. Once you place your cursor in that box, the ribbon will display the Search Tools options. To find all messages with attachments, select the Has Attachments button.
See http://railscasts.com/episodes/206-action-mailer-in-rails-3
def registration_confirmation(user)
@user = user
attachments["rails.png"] = File.read("#{Rails.root}/public/images/rails.png")
mail(:to => "#{user.name} <#{user.email}>", :subject => "Registered")
end
You should be using Action Mailer that's built into Rails which supports sending emails with attachments.
For Rails 3.x - http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-attachments
For Rails 2.3.8+ - http://guides.rubyonrails.org/v2.3.8/action_mailer_basics.html#sending-multipart-emails-with-attachments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With