Setting up a Gmail Account to work with ActionMailer in Rails 3

风流意气都作罢 提交于 2019-11-27 05:08:06

问题


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:

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!


回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/4929680/setting-up-a-gmail-account-to-work-with-actionmailer-in-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!