【问题标题】:how to set up restful_authentication email activation using gmail SMTP?如何使用 gmail SMTP 设置 restful_authentication 电子邮件激活?
【发布时间】:2010-10-22 04:47:51
【问题描述】:

我已经通过激活安装了来自 technoweenie 的 restful_authentcation,所以我看到了生成的 UserMailer

但是,说明不包括如何设置它以使用 Google SMTP。

猜测 environment/development.rb 需要有 SMTP 设置,但仍然不确定 Google(通过 Google 应用程序)是否都是 TLS。

有人使用 restful_authentication 设置激活吗?

我目前将以下内容放入environments.rb:

 ActionMailer::Base.smtp_settings = {
     :enable_starttls_auto => true,
     :address => "smtp.gmail.com",
     :port => "587",
     :domain => "mydomain.com",
     :authentication => :plain,
     :user_name => "xxx@mydomain.com",
     :password => "mypassword"

}

谢谢!!

【问题讨论】:

    标签: ruby-on-rails gmail restful-authentication


    【解决方案1】:

    我从未使用过来自 ruby​​ 的 SMTP(我有来自 python 的),但是 看起来 是对的。您拥有正确的域和端口(实际上,支持多个端口,但这是其中之一),并且您正在使用谷歌使用的 starttls 和 AUTH PLAIN。

    【讨论】:

    • 视线,它不起作用:530 5.7.0 必须先发出 STARTTLS 命令。 l31sm1276848rvb.39
    • 是的。不过,我不知道为什么您的 ruby​​ 库不为您这样做。
    【解决方案2】:

    据我所知,ActionMailer 没有开箱即用的 TLS (2.3.2)。几个月前,我遇到了同样的问题,在一个日文页面上找到了一些代码并将其集成。看来代码现在已经被打包到一个插件中(有英文文档是的!)。这不完全是我使用的,但它宣传相同的效果。

    所以添加这个插件: http://github.com/openrain/action_mailer_tls/tree/master

    在 environment/development.rb 或 environements.rb 中你需要这样的东西:

    ActionMailer::Base.smtp_settings = {
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => "yourdomain.com",
      :user_name => "first.last@gmail.com",
      :password => "passwd",
      :authentication => :plain
    } 
    

    我看到 :enable_starttls_auto => true 现在在文档中,但不是在我开始时。这至少对我有用...

    编辑:由于某种原因,如果您关注该链接,该链接将不起作用,但复制粘贴到地址栏中,它就会生效...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 2016-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多