Rails Mailer: sending emails to a local file

后端 未结 2 1976
轮回少年
轮回少年 2021-01-31 11:39

Is there any way to send emails in rails 3 to a local file or so, instead of using an SMTP server? I\'d like to test the email\'s contents without using any kind of SMTP, ideall

相关标签:
2条回答
  • 2021-01-31 11:48

    You can use the :test system delivery

    ActionMailer::Base.delivery_method = :test
    

    There are also a :file delivery_method

    ActionMailer::Base.delivery_method = :file
    

    You can define where put all email with file_settings

    ActionMailer::Base.file_settings = { :location => Rails.root.join('tmp/mail') }
    
    0 讨论(0)
  • 2021-01-31 12:02

    There is also the letter_opener gem which will save mail to disk and open it in a browser.

    Or mails_viewer which has a Web UI to view the emails instead of opening them in a browser.

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