在开发中使用 Devise 1.3.4 使用 Gmail 发送电子邮件 [英] Getting Devise 1.3.4 to send emails with Gmail in development

查看:40
本文介绍了在开发中使用 Devise 1.3.4 使用 Gmail 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置设计 1.3.4 以在开发模式下通过 gmail 发送电子邮件.我应该提到我使用的是 Rails 3.0.4 和 Ruby 1.9.2p136.

I'm trying to setup devise 1.3.4 to send emails via gmail while in development mode. I should mention that I'm using Rails 3.0.4 and Ruby 1.9.2p136.

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

I've tried the following in 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 中我改变了

And in config/initializers/devise.rb I changed

 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

它仍然无法正常工作.

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

Is there a wiki page on how to get the mailer working? I see the email in my log and it looks great! The links work, etc ... I just want to see them in my email account.

编辑

我找到了答案——我使用了 http://yekmer.posterous.com/devise-gmail-smtp-configuration - 当我应该把它放在 config/environments/development.rb 中时,我已经把它放在了 config/intializers/devise.rb 中.

I found the answer - I used http://yekmer.posterous.com/devise-gmail-smtp-configuration - I had been putting that code in config/intializers/devise.rb when I should have been putting it in config/environments/development.rb.

推荐答案

你试过了吗?

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {  
  :address              => "smtp.gmail.com",  
  :port                 => 587,  
  :domain               => "gmail.com",  
  :user_name            => "myinfo@gmail.com",  
  :password             => "secret",  
  :authentication       => "plain"
  # :enable_starttls_auto => true # I don't have this, but it should work anyway 
} 

--------- 编辑

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

it it's sent maybe you don't receive it because of the spam filter, first thing to check:

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

这篇关于在开发中使用 Devise 1.3.4 使用 Gmail 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆