40

I have a contact page form that is setup to send an email to a Gmail account. Only problem is it won't send. I believe I have narrowed the error down to my settings inside of the initializers directory.

These are my current settings for trying to setup a standard gmail account to send mail: enter image description here

Could it be that my domain setting is wrong or should I be typing in myemail@gmail.com for :user_name? This is the first time I have used ActionMailer so I don't really know what I am doing. Can somebody please help me out!? Thanks!

ab217
  • 16,900
  • 25
  • 74
  • 92
  • 2
    Those settings should work perfectly as long as you have an @gmail.com address. Can you post your mailer code and whatever code is calling it? – Dylan Markow Feb 08 '11 at 05:01
  • I am followed this RailsCast tutorial to the letter which is why I thought this code was causing the problem: because it is the only thing that differed. The tutorial can be found at http://railscasts.com/episodes/206-action-mailer-in-rails-3 – ab217 Feb 08 '11 at 05:17

3 Answers3

43

If you are using the development environment, change the development.rb to raise delivery errors, with config.action_mailer.raise_delivery_errors = true

Also, the problem might be that :user_name should be the entire email address (myemail@gmail.com), that's how Gmail authenticates users.

eugen
  • 8,916
  • 11
  • 57
  • 65
  • I have that enabled, and I have tried using `myemail@gmail.com` in the `:user_name` field but it never raises an exception when I send it. – ab217 Feb 08 '11 at 11:33
  • 11
    **I restarted the rails server** and used `myemail@gmail.com` and it worked! Thanks a lot!!! – ab217 Feb 08 '11 at 11:43
0

domain does not necessarily have to be "gmail.com". You can put your own domain here is you wish.

RonanOD
  • 876
  • 1
  • 9
  • 19
0

You also need to specify :from. I found that if you deliver your email with .deliver you do not get an exception for the errors. Try .deliver! instead. With .deliver! you get details about what is wrong.