Configure actionmailer to send mail via Gmail by YuanYi Zhang | published: November 26,200 8
This problem has been around for a long time. I compared several existing solutions and found that the Robert bousquet solution is the simplest.
1. Robert only provides a source code download link, which is not very convenient. I put it on GitHub:
$ script/plugin install git://github.com/yzhang/smtp_tls.git
2. Modify environment. RB:
require "smtp_tls"
mailer_config = File.open("#{RAILS_ROOT}/config/mailer.yml")
mailer_options = YAML.load(mailer_config)
ActionMailer::Base.smtp_settings = mailer_options
3. Create config/mailer. yml
-
: Address: smtp.gmail.com
Port: 587
: User_name: john@doe.com
: Password: s1j234gh
: Authentication: Plain
4. If you use the exceptionnotification plug-in, make sure that the sender settings of exceptionnotification are consistent with your Gmail account; otherwise, Gmail will reject sending.
From: www.letrails.cn