LoginSignup
1
2

More than 3 years have passed since last update.

【Rails】Action Mailerのメール送信に失敗する

Last updated at Posted at 2020-02-04

症状

Action Mailerを利用したメール送信処理で、以下のエラーを吐いてしまう。
なお以前は正常に送信することができていた。

Net::SMTPAuthenticationError (530 Authentication required):

ArgumentError (SMTP To address may not be blank: []):

原因

環境変数を正常に読み込めていなかった。
SMTP認証情報やお問い合わせ宛先メールアドレスを環境変数に入れていたため、それらの情報を利用することができず、送信に失敗した。

根本原因

Circle CIからSSHでデプロイ先のサーバに接続し、シェルスクリプトを実行していた。
この場合は環境変数が読み込まれない。

【参考】[FreeBSD][Linux] ssh経由でコマンド実行すると環境変数を読まないでござる

対処

Circle CIの設定を変更し、.bash_profileを読み込むように変更。

- run:
  name: Start SSH & Deploy
  command: ssh foo@bar "source ~/.bash_profile; bash ~/deploy.sh"
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2