简体   繁体   中英

devise_token_auth email sending issue

I'm using devise_token_auth in my app. When user registers, it automatically sends confirmation email.

from https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/registrations_controller.rb

# ..code
unless @resource.confirmed?
# user will require email authentication
  @resource.send_confirmation_instructions({
    client_config: params[:config_name],
    redirect_url: @redirect_url
})
# ..code

And I get 500 error.

I, [2016-09-01T12:32:06.142856 #15153]  INFO -- : [07ca58ab-1797-4edb-99bb-c7d408bfd2c9] Completed 500 Internal Server Error in 31331ms (ActiveRecord: 8.4ms)
F, [2016-09-01T12:32:06.145874 #15153] FATAL -- : [07ca58ab-1797-4edb-99bb-c7d408bfd2c9]   
F, [2016-09-01T12:32:06.146192 #15153] FATAL -- : [07ca58ab-1797-4edb-99bb-c7d408bfd2c9] Net::OpenTimeout (execution expired):
F, [2016-09-01T12:32:06.146249 #15153] FATAL -- : [07ca58ab-1797-4edb-99bb-c7d408bfd2c9]   
F, [2016-09-01T12:32:06.146292 #15153] FATAL -- : [07ca58ab-1797-4edb-99bb-c7d408bfd2c9] /home/deploy/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/smtp.rb:542:in `initialize'
...

As you can see from the log it times out Net::OpenTimeout (execution expired):

But when I run User.last.send_confirmation_instructions from console it sends the email how it is suppose to be.

What am I suppose to do?

Thanks!

The problem was because of ipv6.

To fix it I had to edit /etc/gai.conf by uncommenting #precedence ::ffff:0:0/96 100 line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM