Tuesday, September 16, 2008

Rails ActionMailer on Site5 2

So, it turned out that it wasn't as straight forward as I thought. I dumped the config stuff after the 'Rails::Initializer.run do |config| ' part in environment.rb and tried to send an email. The server timed out and gave a 'Rails Application failed to start' error, which meant that the fcgi process was being killed (I looked in the site's error log in Backstage to figure this out.)

Couldn't work out what was going on, because it had worked in the console. Eventually I went back to the console. I tried
ActionMailer::Base.smtp_settings

to see what settings it was reading. It dumped a load of default-looking settings to the command line. Somewhere my configuration settings were being over-ridden.

Eventually I discovered that this was happening in config/initializers/mail.rb. It seems that the initializers are run after the main initializer stuff in environment.rb. I put my config stuff in there instead and it worked :) .

No comments: