Email attachments

前端 未结 3 958
后悔当初
后悔当初 2021-01-12 00:28

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

相关标签:
3条回答
  • 2021-01-12 01:21

    For alternative consideration, I personally have had a good experience using Pony for email. It happens to have a lot of gem dependencies, but it is very nice to work with. See the README for more information.

    0 讨论(0)
  • 2021-01-12 01:27

    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
    
    0 讨论(0)
  • 2021-01-12 01:30

    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

    0 讨论(0)
提交回复
热议问题