让Devise 1.3.4发送邮件与Gmail开发中 [英] Getting Devise 1.3.4 to send emails with Gmail in development
问题描述
我正在设计devise 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-配置
它仍然不起作用。
有没有一个维基页面,如何获得邮寄员工作?我看到我的日志中的电子邮件,看起来不错!链接工作等...我只想在我的电子邮件帐户中看到他们。
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 / intializers / devise.rb当我应该把它放在配置/环境/开发.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
}
- ------- 编辑
--------- EDIT
它发送可能是因为垃圾邮件过滤器而没有收到,首先要检查:
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屋!