sscirrus
sscirrus

Reputation: 56719

Rails 3: SMTP Settings for Google Apps / Heroku

Here are my smtp settings for Google Apps in setup_mail.rb.

  :address              => "smtp.gmail.com",  
  :port                 => 587,                 
  :domain               => 'mysite.co',  
  :user_name            => '[email protected]',      
  :password             => 'password',      
  :authentication       => 'plain',             
  :enable_starttls_auto => true

My development logs show in detail the e-mails being generated and sent to the right e-mail address... but they are not arriving. I can only think that there must be something wrong with the settings above. Can you see what the problem is?

Once this is solved, would I have any issue getting it to work on Heroku?


Note: the above is logging a deprecation warning:

DEPRECATION WARNING: Giving a hash to body is deprecated, please use instance va
riables instead. (called from process at C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gem
s/actionmailer-3.0.0/lib/action_mailer/old_api.rb:77)

Upvotes: 6

Views: 9896

Answers (4)

Pete Brumm
Pete Brumm

Reputation: 1696

in your user controller don't forget to add the .deliver

UserMailer.registration_confirmation(@user).deliver

that is what stumped me

Upvotes: 5

Syamantak
Syamantak

Reputation: 51

I think if you are using rails 3, the correct approach to setup mail would be to follow this railscasts tutorial on action mailer.

Upvotes: 5

sscirrus
sscirrus

Reputation: 56719

Turned out that the issue was elsewhere - an old AuthLogic tutorial had put me in the right direction on sending out activation codes but the wrong direction on sending out the e-mails themselves. Rails was generating the e-mail but not sending it because the mail_helper's code wasn't going the final step.

If you're reading this in retrospect, what I learned: make sure your Rails 3.0 user_mailer has (or similar):

mail(:to => "#{user.login} <#{user.email}>", :subject => "Registered" )

Upvotes: 2

mark
mark

Reputation: 10564

I haven't used rails3 but I remember reading that sent emails in development are sent to the sender. Your deprecation warning is because you're defining variables for the email template in the previous hash format. Rails 3 works differently. In my experience deploying to heroku works flawlessly but you will need to define mx records.

Upvotes: 0

Related Questions