这个问题由来已久,比较了一下几种现有的解决方案,最后发现Robert Bousquet的方案是最简单的。

1. Robert只提供了一个源码下载链接,不是很方便,我将它放到了github上:


$ script/plugin install git://github.com/yzhang/smtp_tls.git

2. 修改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. 建立config/mailer.yml


  :address: smtp.gmail.com
  :port: 587
  :user_name: john@doe.com
  :password: s1j234gh
  :authentication: :plain

4. 如果你使用了ExceptionNotification插件,那么你需要确保ExceptionNotification的发件人设置与你的Gmail帐户相符,否则GMail将会拒绝发送。

摘自:www.letrails.cn

相关文章:

  • 2021-11-16
  • 2020-01-19
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-10-07
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-08-15
  • 2021-06-12
  • 2022-12-23
  • 2021-08-05
相关资源
相似解决方案