Category Archives: 邮件

配置ActionMailer使用GMail发送邮件

这个问题由来已久,比较了一下几种现有的解决方案,最后发现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将会拒绝发送。

Posted in 邮件 | 3 Comments