質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

5603閲覧

rails4 devise 確認メールを送れない

M8KzBFdJPyD1kKd

総合スコア26

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2016/04/23 12:52

編集2016/04/23 12:58

rails4 cloud9の環境でdevise を用いて、確認メールを送るようにしたい

いろいろやってみたが、次のとおりのエラーが・・・

Net::OpenTimeout in Devise::RegistrationsController#create
execution expired

Extracted source (around line #541):

def tcp_socket(address, port)
TCPSocket.open address, port
end

def do_start(helo_domain, user, secret, authtype)

私がいろいろとやったことは次のとおり
エラーだらけで、ひとつづつ直していった!
が結局のところ、上のタイムアウトとか言うエラーで行き詰った・・・

一体、何が悪いのでしょうか・・・とほほ

###1.userのマイグレーションファイルというのでしょうか?そいつの#をどけました。

## Confirmable t.string :confirmation_token t.datetime :confirmed_at t.datetime :confirmation_sent_at t.string :unconfirmed_email # Only if using reconfirmable add_index :users, :confirmation_token, unique: true

###2.production.rb に次を入れました

config.action_mailer.default_url_options = { host: '〇〇c9users.io' }

###3.confirmation_instructions.html.erb のパスをnew_user_confirmation_pathに修正しました

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> <%= link_to t('.didn_t_receive_confirmation_instructions', :default => "Didn't receive confirmation instructions?"), new_user_confirmation_path(resource_name) %><br /> <% end -%>

###4.confirmation_instructions.html.erb の『confirmation_url()』を『user_confirmation_url()』に修正

<p><%= link_to t('.action', :default => "Confirm my account"), user_confirmation_url(@resource, :confirmation_token => @token, locale: I18n.locale) %></p>

###5.development.rb に次を書き加えました

config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true host = '〇〇c9users.io' config.action_mailer.default_url_options = { host: host } config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => 'smtp.gmail.com', :port => '2525', :authentication => :plain, :user_name => '〇〇〇@gmail.com', :password => '△△', :domain => 'smtp.gmail.com', :enable_starttls_auto => true }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

下記リンクが参考になるのではないでしょうか。
Railsでメール配信してみる。 Action Mailer

gmailの場合はgmailの2段階認証をしてから、そこで発行されるパスワードを下記コードでセットしておかないとメール送信はできないです。

ruby

1> 引用テキスト一旦Action Mailerを離れて、アプリケーションにGmailにてメール配信する設定を施します。 2 3# config/environments/development.rb 4> Rails.application.configure do 5> () 6> config.action_mailer.raise_delivery_errors = true 7> config.action_mailer.delivery_method = :smtp 8> config.action_mailer.smtp_settings = { 9> address: 'smtp.gmail.com', 10> port: 587, 11> user_name: 'あなたのGメールアドレス', 12> password: '2段階認証で得たパスワード', 13> authentication: 'plain', 14> enable_starttls_auto: true } 15> () 16> end

どうでしょうか。

投稿2016/04/23 13:50

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

M8KzBFdJPyD1kKd

2016/04/24 03:44

やってみました 2段階パスワードの12桁を入れてやってみました 次は、下のエラーが出ました。。。 Something went wrong ! Server timed out or sent incomplete response Click here to try again. (Perhaps you meant to use HTTPS instead of HTTP?) If that still doesn't work, please Issue a bug report. もしかしてHTTPSを使うつもりでした? ならココ押して! って言うので押すと、上記と同じエラー内容が表示されます If that still doesn't work, please Issue a bug report.ってことで、バグ報告行きになりました(><)
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問