Getting Devise 1.3.4 to send emails with Gmail in development

后端 未结 4 1378
鱼传尺愫
鱼传尺愫 2020-12-09 06:10

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 th

相关标签:
4条回答
  • 2020-12-09 06:48

    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            => "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
    
    0 讨论(0)
  • 2020-12-09 06:52

    Check if the value of ActionMailer::Base.delivery_method is :smtp

    0 讨论(0)
  • 2020-12-09 07:06

    I think you can change it inside config/initializers/devise.rb. No need for a new class I think?

    #config/initializers/devise.rb
    config.mailer_sender = 'youremail@gmail.com'
    
    0 讨论(0)
  • 2020-12-09 07:07

    you should put that in devise initializer :

    # Configure the class responsible to send e-mails.
      config.mailer = "YourAppDeviseMailer"
    

    Then create a class that extends Devise::Mailer :

    class YourAppDeviseMailer < Devise::Mailer
      default :from => 'your_email'
    
      def self.mailer_name
        "devise/mailer"
      end
    end
    
    0 讨论(0)
提交回复
热议问题