我正在尝试通过亚马逊SES在Rails应用程序中发送电子邮件。
该用户故事是
这是我的代码。
配置/环境/ development.rb
Rails.application.configure do
...
# deviseの設定
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'email-smtp.us-east-1.amazonaws.com',
port: 587,
authentication: :login,
user_name: '[SES UserName]',
password: '[SEP Password]',
enable_starttls_auto: true
}
end
应用程序/邮寄者 (这里只有application_mailer.rb)
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
end
日志/ development.log
Started POST "/users/password" for 172.18.0.1 at 2017-09-27 02:55:35 +0000
...
<p>Hello test@gmail.com!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><a href="http://localhost:3000/users/password/edit?reset_password_token=EoGaE1UF2KjTNFLGHhvQ">Change my password</a></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
Completed 500 Internal Server Error in 6247ms (ActiveRecord: 4.1ms)
Net::SMTPFatalError (553 <localhost:3000> Invalid email address.
):
/usr/local/lib/ruby/2.4.0/net/smtp.rb:969:in `check_response'
/usr/local/lib/ruby/2.4.0/net/smtp.rb:937:in `getok'
/usr/local/lib/ruby/2.4.0/net/smtp.rb:837:in `mailfrom'
/usr/local/lib/ruby/2.4.0/net/smtp.rb:658:in `send_message'
mail (2.6.6) lib/mail/network/delivery_methods/smtp.rb:112:in `block in deliver!'
...
puma (3.9.1) lib/puma/server.rb:435:in `process_client'
puma (3.9.1) lib/puma/server.rb:299:in `block in run'
puma (3.9.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Completed 500 Internal Server Error in 84ms (Views: 73.1ms | ActiveRecord: 0.0ms)
我认为问题的中心就是这个。
Net::SMTPFatalError (553 <localhost:3000> Invalid email address.):
但我无法解决这个问题。
如何解决?
答案 0 :(得分:0)
有同样的问题。
您是否尝试设置自己的电子邮件地址? 您无法从弹出的电子邮件地址发送。
希望它有所帮助。