Rails emails not sending in staging environment
Posted
by
jrdioko
on Stack Overflow
See other posts from Stack Overflow
or by jrdioko
Published on 2011-01-05T01:00:05Z
Indexed on
2011/01/06
4:54 UTC
Read the original article
Hit count: 344
In a Rails application I set up a new staging environment with the following parameters in its environments/
file:
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
However, when the system generates an email, it gets printed to the staging.log
file instead of being sent. My SMTP settings work fine in other environments. What configuration am I missing to get the emails to actually send?
Edit: Yes, the staging box is set up with valid configuration for an SMTP server it has access to. It seems like the problem isn't with the SMTP settings (if it was, wouldn't I get errors in the logs?), but with the Rails configuration. The application is still redirecting emails to the log file (saying "Sent mail: ...") as opposed to actually going through SMTP.
Edit #2: It looks like the emails actually have been sending correctly, they just happen to print to the log as well. I'm trying to use the sanitize_email
gem to redirect the mail to another address, and that doesn't seem to be working, which is why I thought the emails weren't going out. So I think that solves my problem, although I'm still curious what in ActionMailer's settings controls whether emails are sent, logged to the log file, or both.
Edit #3: The problem with sanitize_email
boiled down to me needing to add the new staging environment to ActionMailer::Base.local_environments
. I'll keep this question open to see if anyone can answer my last question (what determines whether ActionMailer's emails get sent out, logged to the log file, or both?)
© Stack Overflow or respective owner