加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 让Devise 1.3.4在开发中使用Gmail发送电子邮件

发布时间:2020-12-16 19:05:20 所属栏目:百科 来源:网络整理
导读:我正在尝试设置设计1.3.4,以便在开发模式下通过Gmail发送电子邮件.我应该提一下,我使用的是Rails 3.0.4和 Ruby 1.9.2p136. 我在config / environments / development.rb中尝试了以下内容: config.action_mailer.raise_delivery_errors = trueconfig.action_
我正在尝试设置设计1.3.4,以便在开发模式下通过Gmail发送电子邮件.我应该提一下,我使用的是Rails 3.0.4和 Ruby 1.9.2p136.

我在config / environments / development.rb中尝试了以下内容:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true

config.action_mailer.default_url_options = { :host => 'mydomain.com' }

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

在config / initializers / devise.rb中我改变了

config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"

config.mailer_sender = "info@mydomain.com"

然后我试了一下

http://yekmer.posterous.com/devise-gmail-smtp-configuration

它仍然无法正常工作.

是否有关于如何让邮件工作的维基页面?我在日志中看到了电子邮件,看起来很棒!链接工作等…我只想在我的电子邮件帐户中看到它们.

编辑

我找到了答案 –
我使用了http://yekmer.posterous.com/devise-gmail-smtp-configuration – 当我将它放在config / environments / development.rb中时,我一直把这些代码放在config / intializers / devise.rb中.

解决方法

你试过这个吗?
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {  
  :address              => "smtp.gmail.com",:domain               => "gmail.com",:user_name            => "myinfo@gmail.com",:authentication       => "plain"
  # :enable_starttls_auto => true # I don't have this,but it should work anyway 
}

———编辑

它发送可能你没有收到它因为垃圾邮件过滤器,首先要检查:

class UserMailer < ActionMailer::Base
  default :from => "myinfo@gmail.com"
  # ...
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读