Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
559 views
in Technique[技术] by (71.8m points)

ruby on rails - Getting Devise 1.3.4 to send emails with Gmail in development

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.

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  
}  

And in config/initializers/devise.rb I changed

 config.mailer_sender = "[email protected]"

To

 config.mailer_sender = "[email protected]"

Then I tried

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

It's still not working.

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.


Edit

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Have you tried this?

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {  
  :address              => "smtp.gmail.com",  
  :port                 => 587,  
  :domain               => "gmail.com",  
  :user_name            => "[email protected]",  
  :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 => "[email protected]"
  # ...
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...