サインアップ時のメール送信が意図した通り動作しない
サインアップ(devise)した時に、登録したメールアドレスにメッセージを送られるようにしたいが、登録時に止まってしまい、送ることができない状態にいます。
もしわかる方がいらしたら、教えて頂きたいです。
問題:登録を押した際に起きたエラー(上の動作の後に)
Completed 500 Internal Server Error in 845ms (ActiveRecord: 52.6ms)
Net::SMTPFatalError (555 5.5.2 Syntax error. p136sm891772lfp.86 - gsmtp
):
app/models/tourist.rb:13:in `send_welcome_mail'
Terminal結果
TouristMailer#tourist_welcome_mail: processed outbound mail in 47.6ms
Sent mail to <@tourist.email> (545.9ms)
Date: Sat, 04 May 2019 14:28:54 +0300
From: chancetochance2018@gmail.com
To: <@tourist.email>
Message-ID: <5ccd7776e7305_ab733fbfc403e49010004a@ishiwatadohiroshi-no-MacBook-Air.local.mail>
Subject: =?UTF-8?Q?=E3=81=8A=E5=95=8F=E3=81=84=E5=90=88=E3=82=8F=E3=81=9B?=
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5ccd7776e1b11_ab733fbfc403e49099912";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_5ccd7776e1b11_ab733fbfc403e49099912
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: base64
SGlybyDmp5jjgYvjgonllY/jgYTlkIjjgo/jgZvjgYzjgYLjgorjgb7jgZfj
gZ/jgIINCg0K44O744GK5ZWP44GE5ZCI44KP44GbDQoNCg0K
----==_mimepart_5ccd7776e1b11_ab733fbfc403e49099912
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>=0D
<body>=0D
<!doctype html>=0D
<html lang=3D"ja">=0D
<head>=0D
<meta content=3D"text/html; charset=3DUTF-8" />=0D
</head>=0D
<body>=0D
<h2>Hiro =E6=A7=98</h2>=0D
<hr />=0D
<p>=0D
=E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF=EF=BC=81 Hiro=E3=81=95=E3=
=82=93=EF=BC=81</p>=0D
<hr />=0D
</body>=0D
</html>=0D
=0D
</body>=0D
</html>=0D
----==_mimepart_5ccd7776e1b11_ab733fbfc403e49099912--
(9.5ms) ROLLBACK
Completed 500 Internal Server Error in 845ms (ActiveRecord: 52.6ms)
Net::SMTPFatalError (555 5.5.2 Syntax error. p136sm891772lfp.86 - gsmtp):
app/models/tourist.rb:13:in `send_welcome_mail'
実際のコード
views/tourist_welcome_mailer.html.erb
<!doctype html>
<html lang="ja">
<head>
<meta content="text/html; charset=UTF-8" />
</head>
<body>
<h2><%= @tourist.name %> 様</h2>
<hr />
<p>
こんにちは! <%= @tourist.name %>さん!</p>
<hr />
</body>
</html>
mailers/tourist_mailer.rb
class TouristMailer < ApplicationMailer
default from: '<chancetochance2018@gmail.com>'
def tourist_welcome_mail(tourist)
@tourist = tourist
mail(
from: '<chancetochance2018@gmail.com>',
to: '<'+'@tourist.email'+'>',
subject: 'お問い合わせ'
)
end
end
model/tourist.rb
after_create :send_welcome_mail
def send_welcome_mail
TouristMailer.tourist_welcome_mail(self).deliver_now
end
config/development.rb
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'smtp.gmail.com',
user_name: 'chancetochance2018@gmail.com',
password: '???????????',
authentication: 'plain',
enable_starttls_auto: true
}