2016-05-03 7 views
1

私はdeviseを使ってサインアップした後に送信される確認メールを設定しています。私はこれが言っていることすべて(https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users)をやったが、それでも動作しません。Railsは開発の確認メールを送信しないように工夫しています

ここではいくつかのコードは次のとおりです。

//development.rb 
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 

//devise.rb 
    config.mailer_sender = '[email protected]' 
    # Configure the class responsible to send e-mails. 
    config.mailer = "Mailer" 

//Mailer.rb 
class Mailer < Devise::Mailer 
    helper :application 
    include Devise::Controllers::UrlHelpers 
    default template_path: 'devise/mailer' 
end 

が、私は開発環境で電子メールの確認メールを送信するために、より多くの何かを設定する必要がありますか?

答えて

2

はい、あなたはなどから送信されるEメールのSMTP設定を構成する必要があります。

require 'tlsmail' 
    Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) 
    ActionMailer::Base.delivery_method = :smtp 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.default :charset => "utf-8" 
     ActionMailer::Base.smtp_settings = { 
     :address    => "smtp.gmail.com", 
     :port     => 587, 
     :user_name   => "YOUR_EMAIL", 
     :password    => 'PASSWORD', 
     :authentication  => "plain", 
     :enable_starttls_auto => true 
     } 

smtp設定を構成するために、あなたのdevelopment.rbに、コードの上に追加します。必要に応じてコードに電子メールとパスワードを追加してください。 うまくいけばうまくいくでしょう!ムハンマドの答え@に加えて

+0

上のコードのこれらの行はねえ、私はこれをやってみましたし、実際に誰かがログインしようとした」と言ってGoogleからのエラーを得た含めます"これを解決する方法はありますか? – Kahsn

+0

はい、Googleアカウントの設定で「ログイン&セキュリティ」 - >「安全性の低いアプリを許可する」を探して有効にします。 –

1

、またあなたのdevelopment.rb

config.action_mailer.default_url_options = {host: 'your server' } # ex. localhost:3000 
config.action_mailer.raise_delivery_errors = true # to raise error if smtp has error on setup 
config.action_mailer.default :charset => "utf-8" 
関連する問題