I’m using gmail to send out emails from my application. Anticipating very low traffic but maybe more than enough that I might hit gmail mail limits so I’m setting it up (in my application controller) to use two different accounts depending on the time of day.
I’ve used this set up before successfully but now that I’ve introduced the “greater than” or “less than” symbols I’m getting an error message about the “when.” In another application I did
when Time.now == 1
....
when Time.now == 2
...etc
and it worked fine.
Can anyone tell me what’s wrong with this?
case
when Time.now.hour > 12
ActionMailer::Base.smtp_settings = {
:user_name => "blahblahblah@gmail.com",
:password => ENV['GMAIL_PASS'],
:address => "smtp.gmail.com",
:port => 587,
:tls => true
}
when Time.now.hour < 12
ActionMailer::Base.smtp_settings = {
:user_name => "blahblah@gmail.com",
:password => ENV['GMAIL_PASS'],
:address => "smtp.gmail.com",
:port => 587,
:tls => true
}
end
Why use a case statement with only 2 options? A very simple and more elegant way of accomplishing what you want to do is:
Then you will get a random distribution that over time will be 50/50. I think using gmail in general though for bulk mailing is bad. Any decent host can give you a SMTP server.