How can I do disable email delivery in development mode?

61 views
Skip to first unread message

Jaimin Pandya

unread,
Jun 23, 2014, 5:41:54 AM6/23/14
to rubyonra...@googlegroups.com
Is it any way to do disable email delivery in development mode?


Kind regards.

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Jun 23, 2014, 6:00:54 AM6/23/14
to rubyonra...@googlegroups.com
On 23 June 2014 10:41, Jaimin Pandya <li...@ruby-forum.com> wrote:
> Is it any way to do disable email delivery in development mode?

You can test which environment is currently running and not send the
email in development.
See http://apidock.com/rails/Rails/env/class

Colin

Jaimin Pandya

unread,
Jun 23, 2014, 6:31:37 AM6/23/14
to rubyonra...@googlegroups.com
Is their any way to add code in development.rb file and i can disable
email delivery?

Rafi A

unread,
Jun 23, 2014, 6:43:41 AM6/23/14
to rubyonra...@googlegroups.com
Hi,

development.rb is environment specific file. It wont work when you run application in production mode. So if you want to have access to single file which you want to run in all the modes, better have the mailer code in environment.rb / application.rb file with environment conditions as said in previous mail.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/06611fc97a7a56b75caf4f64ee9152ce%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Jaimin Pandya

unread,
Jun 23, 2014, 6:53:01 AM6/23/14
to rubyonra...@googlegroups.com
> development.rb is environment specific file. It wont work when you run
> application in production mode. So if you want to have access to single
> file which you want to run in all the modes, better have the mailer code
> in
> environment.rb / application.rb file with environment conditions as said
> in
> previous mail.

Thank you.

Frederick Cheung

unread,
Jun 23, 2014, 9:04:08 AM6/23/14
to rubyonra...@googlegroups.com


On Monday, June 23, 2014 10:41:54 AM UTC+1, Ruby-Forum.com User wrote:
Is it any way to do disable email delivery in development mode?



If you set

config.action_mailer.delivery_method = :test

in development.rb

Then no emails will get send (assuming you don't have something somewhere else (for example in an initializer) that overrides that. A nice development tool is mailcatcher - it runs a fake smtp server for you, you set your app to connect to localhost:1025 in development, eg

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings =   {:address => "localhost",  :port => 1025}

And all the email your app sends shows up in a web app you can access at localhost:1080

Fred


Greg Akins

unread,
Jun 23, 2014, 9:15:00 AM6/23/14
to rubyonra...@googlegroups.com
On Monday, June 23, 2014 10:41:54 AM UTC+1, Ruby-Forum.com User wrote:
>>
>> Is it any way to do disable email delivery in development mode?
>>

I use https://github.com/pboling/sanitize_email to force all emails to
be sent to one pre-defined email address.

Jaimin Pandya

unread,
Jun 23, 2014, 12:43:50 PM6/23/14
to rubyonra...@googlegroups.com
> On Monday, June 23, 2014 10:41:54 AM UTC+1, Ruby-Forum.com User wrote:
>> Is it any way to do disable email delivery in development mode?
>>
>>
>>
> If you set
>
> config.action_mailer.delivery_method = :test
>
> in development.rb
>
> Then no emails will get send (assuming you don't have something
> somewhere
> else (for example in an initializer) that overrides that.

I am looking for this type of answer. Thank you very much.

Damián M. González

unread,
Jun 23, 2014, 6:37:06 PM6/23/14
to rubyonra...@googlegroups.com
Just do in development.rb config file:

config.action_mailer.perform_deliveries = false

Max

unread,
Jun 24, 2014, 8:36:06 AM6/24/14
to rubyonra...@googlegroups.com

I recommend using the letter opener gem.  it's fantastic for development - check it out:


 

James Davis, PhD

unread,
Jun 25, 2014, 7:47:35 AM6/25/14
to rubyonra...@googlegroups.com
It explains how to use letter_opener. 
Reply all
Reply to author
Forward
0 new messages