ECS:本番環境でメールを送りたい

実現したいこと

前提

・Dockerを使用している
・Deviseを使用したユーザー認証をしている
・ECSにgithub actionsを使ってデプロイしている
・タスク定義の環境変数を設定する箇所で以下を定義
→ ・user_nameに自分のgmailアドレス(SEND_MAIL)
・passwordに2段階認証onにして生成されたアプリパスワード(GMAIL_SPECIFIC_PASSWORD)

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

Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at [c20ddd92-4960-444a-8fc7-da58d3bed6b6] [c20ddd92-4960-444a-8fc7-da58d3bed6b6] app/controllers/users/confirmations_controller.rb:20:in `create'

該当のソースコード

ruby

1# production.rb2 3config.action_mailer.perform_caching = false4 5 config.action_mailer.default_url_options = { host: 'ruote53で作成したドメイン名' } 6 7 config.action_mailer.perform_deliveries = true8 9 config.action_mailer.delivery_method = :smtp10 11 config.action_mailer.smtp_settings = {12 address: "smtp.gmail.com",13 domain: 'gmail.com',14 port: 587,15 user_name: ENV.fetch('SEND_MAIL', nil),16 password: ENV.fetch('GMAIL_SPECIFIC_PASSWORD', nil),17 authentication: :login,18 openssl_verify_mode: 'none',19 enable_starttls_auto: true20 }21 22 config.action_mailer.raise_delivery_errors = true

# app/views/users/mailer/confirmation_instructions.html.erb <p>Welcome <%= @email %>!</p> <p>You can confirm your account email through the link below:</p> <p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token, only_path: true) %></p>
# app/controllers/users/confirmations_controller.rb def create self.resource = resource_class.send_confirmation_instructions(resource_params) yield resource if block_given? if successfully_sent?(resource) respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name)) else respond_with(resource) end end

試したこと

・タスク定義に設定した環境変数名前と値の確認
・host名を直書きで記述した
・host名をecsインスタンスのパブリックIPアドレスに変更して定義

補足情報(FW/ツールのバージョンなど)

user_nameと passwordも間違っていないように感じます。
またタスク定義内に設定した環境変数が参照されていないようにも感じます。
また前回のイメージのキャッシュが残っているようにも見受けられます
→github actionsにて自動デプロイしているため
ECSにデプロイした時は特別必要なことが別途あるのでしょうか?

コメントを投稿

0 コメント