用于用户确认的电子邮件未在生产中发送.Rails,Heroku,Gmail



我已经在谷歌和stackoverflow上寻找答案,但找不到任何解决方案。我正在尝试设置 smtp 电子邮件以在注册后进行用户确认。它在开发中工作正常。即使打开了MailCatcher,它也会以某种方式绕过它,并从我分配的gmail发送到正确的电子邮件。

config.action_mailer.raise_deliver_errors = true
config.action_mailer.perform_deliveries = true
config.assets.raise_runtime_errors = false
config.assets.quiet = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address        => "smtp.gmail.com",
:enable_starttls_auto => true, 
:domain => 'hieu-vo.herokuapp.com',
:port           => 587 ,
:user_name      => 'xxxxx@gmail.com',
:password       => 'xxxxxx',
:authentication => 'plain',
:openssl_verify_mode  => 'none' }
config.action_mailer.default_url_options = { host: 'hieu-vo.herokuapp.com' }

这是我使用heroku logs --tail时的日志

2018-09-11T16:23:35.044137+00:00 app[web.1]: I, [2018-09-11T16:23:35.043151 #4]  INFO -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] Started POST "/users" for 113.188.247.92 at 2018-09-11 16:23:35 +0000
2018-09-11T16:23:35.045638+00:00 app[web.1]: I, [2018-09-11T16:23:35.045531 #4]  INFO -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] Processing by UsersController#create as HTML
2018-09-11T16:23:35.045793+00:00 app[web.1]: I, [2018-09-11T16:23:35.045709 #4]  INFO -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"cJWQmMOh4zUFre1fps03tYuYbbyA8ykZZF3djpwUpe8KWfabD5PUA8ZaC4VQ8VmF9nGVNrxUOomPCRpsKJk7aQ==", "user"=>{"email"=>"mailtest@test.com", "name"=>"hello"}, "commit"=>"Send to me"}
2018-09-11T16:23:35.050036+00:00 app[web.1]: D, [2018-09-11T16:23:35.049890 #4] DEBUG -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55]    (0.6ms)  BEGIN
2018-09-11T16:23:35.055921+00:00 app[web.1]: D, [2018-09-11T16:23:35.055783 #4] DEBUG -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55]   SQL (3.4ms)  INSERT INTO "users" ("name", "email", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["name", "hello"], ["email", "mailtest@test.com"], ["created_at", "2018-09-11 16:23:35.050372"], ["updated_at", "2018-09-11 16:23:35.050372"]]
2018-09-11T16:23:35.059314+00:00 app[web.1]: D, [2018-09-11T16:23:35.059167 #4] DEBUG -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55]    (2.6ms)  COMMIT
2018-09-11T16:23:35.520783+00:00 heroku[router]: at=info method=POST path="/users" host=hieu-vo.herokuapp.com request_id=1b2a2e36-58d4-4845-acfd-2b6fa1621d55 fwd="113.188.247.92" dyno=web.1 connect=1ms service=495ms status=500 bytes=1827 protocol=https
2018-09-11T16:23:35.508523+00:00 app[web.1]: D, [2018-09-11T16:23:35.508354 #4] DEBUG -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] UserMailer#registration_confirmation: processed outbound mail in 447.9ms
2018-09-11T16:23:35.517607+00:00 app[web.1]: I, [2018-09-11T16:23:35.517469 #4]  INFO -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] Sent mail to nhokkonkk13@gmail.com (8.8ms)
2018-09-11T16:23:35.517699+00:00 app[web.1]: D, [2018-09-11T16:23:35.517609 #4] DEBUG -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] Date: Tue, 11 Sep 2018 16:23:35 +0000
2018-09-11T16:23:35.517702+00:00 app[web.1]: From: from@example.com
2018-09-11T16:23:35.517704+00:00 app[web.1]: To: nhokkonkk13@gmail.com
2018-09-11T16:23:35.517706+00:00 app[web.1]: Message-ID: <5b97ec077d6b2_411cabc85239@ba563531-54e7-4e4c-8f59-50279af29818.mail>
2018-09-11T16:23:35.517708+00:00 app[web.1]: Subject: [MAILTO HIEUVO] SOMEONE VISIT YOUR WEBSITE!!!
2018-09-11T16:23:35.517710+00:00 app[web.1]: Mime-Version: 1.0
2018-09-11T16:23:35.517711+00:00 app[web.1]: Content-Type: text/plain;
2018-09-11T16:23:35.517713+00:00 app[web.1]: charset=UTF-8
2018-09-11T16:23:35.517715+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2018-09-11T16:23:35.517716+00:00 app[web.1]:
2018-09-11T16:23:35.517718+00:00 app[web.1]: !!!!!!mailtest@test.com TALK TO YOU: hello
2018-09-11T16:23:35.518083+00:00 app[web.1]: I, [2018-09-11T16:23:35.517991 #4]  INFO -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] Completed 500 Internal Server Error in 472ms (ActiveRecord: 6.6ms)
2018-09-11T16:23:35.519035+00:00 app[web.1]: F, [2018-09-11T16:23:35.518945 #4] FATAL -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55]
2018-09-11T16:23:35.519131+00:00 app[web.1]: F, [2018-09-11T16:23:35.519042 #4] FATAL -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):
2018-09-11T16:23:35.519216+00:00 app[web.1]: F, [2018-09-11T16:23:35.519135 #4] FATAL -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55]
2018-09-11T16:23:35.519334+00:00 app[web.1]: F, [2018-09-11T16:23:35.519255 #4] FATAL -- : [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] app/controllers/users_controller.rb:40:in `block in create'
2018-09-11T16:23:35.519337+00:00 app[web.1]: [1b2a2e36-58d4-4845-acfd-2b6fa1621d55] app/controllers/users_controller.rb:38:in `create'
2018-09-11T16:23:35.932275+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=hieu-vo.herokuapp.com request_id=f7d117e3-a805-41b3-b315-524ce64899c2 fwd="113.188.247.92" dyno=web.1 connect=4ms service=9ms status=200 bytes=143 protocol=https

我想知道我的配置是否错误,但在我的本地机器中它仍然可以工作 fine.so 这可能是 heroku 的用户问题。 非常感谢!

查看此 youtube 视频 youtube.com/watch?v=INPqBOerfTw&t=63s

我更喜欢使用山魈应用程序而不是 gmail https://mandrillapp.com/login/?referrer=%2F

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:domain => 'www.xyz.com',
:user_name => 'xyz',
:password => 'xxx',
:authentication => :plain,
:enable_starttls_auto => true 
} 

最新更新