Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionMailer and development mode, can it write to a file or something?

I want to test my registration process locally (development mode), how can I test how emails will be sent out and rendered etc?

I am not referring to a unit-test or integration test, but just while developing my app and going on the register page etc. I want it to send out the emails but to a file not using smtp.

Is this possible?

What options do I have?

like image 720
Blankman Avatar asked Mar 12 '11 22:03

Blankman


2 Answers

This is configurable in the config/environments/*.rb files.

# output to tmp/mails directory config.action_mailer.delivery_method = :file # ... and to specify output location # config.action_mailer.file_settings = { :location => Rails.root.join('tmp/mail') } 

Detailed information can be found in the config section of Action Mailer Basics or on ActionMailer::Base API


Rails 4.2 :file delivery method source and Mail::FileDelivery source

like image 114
HakonB Avatar answered Sep 25 '22 00:09

HakonB


LetterOpener makes it even simpler for you to preview the emails you just sent by opening the file in the browser automatically (in development environment of course).

like image 30
lulalala Avatar answered Sep 24 '22 00:09

lulalala