I'm having hard time configuring smtp with a rails app. I have done it many times in the past without spree which worked fine. But for some reason, Im not able to get my smtp settings work with spree to send emails.
Here is my configuration:
config.assets.raise_runtime_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 465, # Doesn't work with 587 either
domain: 'gmail.com',
user_name: 'email@gmail.com',
password: 'emailPassword',
authentication: :plain, # Tried :login too
enable_starttls_auto: true
}
I get a couple of errors listed below Net::ReadTimeout: Net::ReadTimeout
and Net::OpenTimeout: execution expired
Below is the stack trace
Net::OpenTimeout: execution expired
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/smtp.rb:541:in `initialize'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/smtp.rb:541:in `open'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/smtp.rb:541:in `tcp_socket'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/smtp.rb:551:in `block in do_start'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/timeout.rb:101:in `call'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/smtp.rb:550:in `do_start'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/smtp.rb:520:in `start'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/mail-2.6.3/lib/mail/message.rb:2141:in `do_delivery'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/mail-2.6.3/lib/mail/message.rb:236:in `block in deliver'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/actionmailer-4.2.1/lib/action_mailer/base.rb:543:in `block in deliver_mail'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `block in instrument'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `instrument'
... 6 levels...
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /home/pamio/dev/rails_apps/local/store/bin/rails:8:in `<top (required)>'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/pamio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/pamio/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'2.1.1 :004 > reload!
I've tried setting up mandrill thinking that gmail might have been blocking my emails but that didnt work either.
Note: I want to be able to configure SMTP with spree3 and I'm not using spree_mail_settings
gem. For some reasons spree_mail_settings
didnt work for me.
Any help will be highly appreciated.
Edit 1: I know my smtp config is fine but may be I must set some spree
related config vars that would let spree use the new config just like in previous versions of spree. I have explored the docs and did not find any help.
Thanks in advance.
A temporary fix can be disabling IPv6. Add following lines to /etc/sysctl.conf:
#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Then from terminal, you can confirm IPv6 (0 means enabled & 1 means disabled):
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
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.