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

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

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

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Gmail

GmailとはGoogleによって提供されているウェブメールのサービスのことです。

Ruby on Rails

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

1回答

2183閲覧

SMTP-AUTH requested but missing user name

divclass123

総合スコア35

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Gmail

GmailとはGoogleによって提供されているウェブメールのサービスのことです。

Ruby on Rails

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/03/12 10:56

このアプリのGitHub

前提・実現したいこと

Docker開発環境上で、会員登録の際にメール認証を行う機能を実装してるときに下記のエラーが起こりました。
以前、ローカルで開発してたときは、起こらなかったので何が悪いのかさっぱりです。。。。

発生している問題・エラーメッセージ

ArgumentError in UsersController#create SMTP-AUTH requested but missing user name
def send_activation_email Rails.logger.debug { Rails.application.config.action_mailer.smtp_settings } UserMailer.account_activation(self).deliver_now #この上の一行がハイライトされてます end end

該当のソースコード

development.rb

Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :amazon # Don't care if the mailer can't send. # config.action_mailer.raise_delivery_errors = true # コメントアウトすることでdelelop環境からもメールを送信する設定に #host = 'b9c7c936bba34db686385a83af09e0a0.vfs.cloud9.ap-northeast-1.amazonaws.com' # ここをコピペすると失敗します。自分の環境のホストに変えてください。 # クラウドIDEの場合は以下をお使いください #config.action_mailer.default_url_options = { host: host, protocol: 'https' } # localhostで開発している場合は以下をお使いください #host = 'localhost:3000' # config.action_mailer.default_url_options = { host: host, protocol: 'http' } config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.hosts.clear #config.action_mailer.asset_host = 'b9c7c936bba34db686385a83af09e0a0.vfs.cloud9.ap-northeast-1.amazonaws.com/' config.action_mailer.default_url_options = { host: 'localhost:3000', protocol: 'http' } config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { # #enable: true, address: 'smtp.gmail.com', port: 587, domain: 'gmail.com', authentication: :login, user_name: '生のgmail', password: '生のアプリパスワード', enable_starttls_auto: true, #openssl_verify_mode: 'peer', ssl: false, tls: false } end

user_controller.rb

def create @user = User.new(user_params) if @user.save @user.send_activation_email flash[:info] = "メールをチェックしてアカウントを有効化してください." redirect_to root_url else render 'new' end end

user.rb

# 有効化用のメールを送信する def send_activation_email Rails.logger.debug { Rails.application.config.action_mailer.smtp_settings } UserMailer.account_activation(self).deliver_now end

試したこと

最初は、

config.action_mailer.smtp_settings = { # #enable: true, address: 'smtp.gmail.com', port: 587, domain: 'gmail.com', authentication: :login, user_name: '生のgmail', password: '生のアプリパスワード', enable_starttls_auto: true, #openssl_verify_mode: 'peer', ssl: false, tls: false }

のuser_nameとpasswordを環境変数を用いてたのですが、
コンテナ内に環境変数が上手く渡ってない可能性があると思ったので、生の数値を直打ちしました。
だけどなぜかエラー内容が変わらずでした。

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

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

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

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

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

guest

回答1

0

自己解決

user_nameとpasswordを直打ちして、コンテナを再起動したら上手くいった。

投稿2021/03/12 11:24

divclass123

総合スコア35

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問