Forum: Ruby on Rails How can I do disable email delivery in development mode?

1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-23 11:41
Is it any way to do disable email delivery in development mode?


Kind regards.
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-23 12:01
(Received via mailing list)
On 23 June 2014 10:41, Jaimin Pandya <lists@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
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-23 12:30
> On 23 June 2014 10:41, Jaimin Pandya <lists@ruby-forum.com> wrote:
> You can test which environment is currently running and not send the
> email in development.
> See http://apidock.com/rails/Rails/env/class

Is their any way to add code in development.rb file and i can disable
email delivery?
Ecff5916fe7b51b8ce0b042ffa960aec?d=identicon&s=25 Rafi A (Guest)
on 2014-06-23 12:44
(Received via mailing list)
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.
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-23 12:52
> 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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2014-06-23 15:05
(Received via mailing list)
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
3272a1c6ef40f33c169fbf8fde60d867?d=identicon&s=25 Greg Akins (akinsgre)
on 2014-06-23 15:16
(Received via mailing list)
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.
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-23 18:43
> 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.

Kind regards.
5b972395a92333843018b4add8af0437?d=identicon&s=25 Damián M. González (igorjorobus)
on 2014-06-24 00:35
Just do in development.rb config file:

config.action_mailer.perform_deliveries = false
D8fd374e9e1811e5b5b8f37b667916bd?d=identicon&s=25 Max Maxwell (aamax)
on 2014-06-24 14:37
(Received via mailing list)
> I recommend using the letter opener gem.  it's fantastic for development -
> check it out:


https://github.com/ryanb/letter_opener
B1994475d62550dfb65f2f802fd48e79?d=identicon&s=25 James Davis, PhD (Guest)
on 2014-06-25 13:49
(Received via mailing list)
On Monday, June 23, 2014 4:41:54 AM UTC-5, Ruby-Forum.com User wrote:
>
> Is it any way to do disable email delivery in development mode?
>
>
> Kind regards.
>
> --
> Posted via http://www.ruby-forum.com/.
>

 Take a look at this Railscast
- http://railscasts.com/episodes/61-sending-email-revised
It explains how to use letter_opener.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.