Dynamic configuration of ActionMailer

50 views
Skip to first unread message

pepe

unread,
Dec 9, 2009, 6:06:52 PM12/9/09
to Ruby on Rails: Talk
Hello,

I have the task of making ActionMailer configurable by a user and be
able to use the new configuration without the need to restart the web
server.

Forgive me if I am mistaken but I believe having ActionMailer
configured in environment.rb will force me to restart the web service.
Is there a way of making the configuration dynamic?

Thanks in advance

Pepe

pepe

unread,
Dec 10, 2009, 9:19:09 AM12/10/09
to Ruby on Rails: Talk
I'm sorry, I meant 'restart the web server' instead of 'restart the
web service'.

My apologies.

Kristian Hellquist

unread,
Dec 10, 2009, 9:37:34 AM12/10/09
to rubyonra...@googlegroups.com
You could read the desired data from a file or database and update
your ActionMailer::Base.configuration before you send a mail.

pepe

unread,
Dec 10, 2009, 7:35:54 PM12/10/09
to Ruby on Rails: Talk
Thanks Kristian.

I've thought about this and what I would probably do is store the
information for ActionMailer in a YAML file. Getting the data is not a
problem, the problem is how to make ActionMailer use the changed
configuration without restarting the web server.

If I am not mistaken if the configuration is in environment.rb, when
the web server starts it runs environment.rb and the configuration is
set, in memory and will not change unless the web server (btw, I am
using Mongrel only, for a very tiny in-house site) is restarted.

What I would like to know is how to change the configuration so when I
change the values after a user makes a change the next e-mail sent
uses the new configuration without the need to restart the web server.

On Dec 10, 9:37 am, Kristian Hellquist <kristian.hellqu...@gmail.com>
wrote:

Kristian Hellquist

unread,
Dec 11, 2009, 2:53:05 AM12/11/09
to rubyonra...@googlegroups.com
2009/12/11 pepe <Pe...@betterrpg.com>:
> Thanks Kristian.
>
> I've thought about this and what I would probably do is store the
> information for ActionMailer in a YAML file. Getting the data is not a
> problem, the problem is how to make ActionMailer use the changed
> configuration without restarting the web server.
>
> If I am not mistaken if the configuration is in environment.rb, when
> the web server starts it runs environment.rb and the configuration is
> set, in memory and will not change unless the web server (btw, I am
> using Mongrel only, for a very tiny in-house site) is restarted.
>
> What I would like to know is how to change the configuration so when I
> change the values after a user makes a change the next e-mail sent
> uses the new configuration without the need to restart the web server.

The class-methods `delivery_method', `smtp_settings' and
`sendmail_settings' on ActionMailer::Base can maybe help you.

pepe

unread,
Dec 11, 2009, 4:32:05 PM12/11/09
to Ruby on Rails: Talk
Will play with it. Thanks a lot. :)

On Dec 11, 2:53 am, Kristian Hellquist <kristian.hellqu...@gmail.com>
wrote:
> 2009/12/11 pepe <P...@betterrpg.com>:

maryam kamali

unread,
Dec 11, 2009, 5:09:26 PM12/11/09
to rubyonra...@googlegroups.com

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.



Reply all
Reply to author
Forward
0 new messages