I am trying to send email using SMTP
server onheroku run rails console
but getting some error. But it is working absolutely fine on local system, not able to understand what's the problem.
Code:
message = <<MESSAGE_END
From: Jobs<notification@example.com>
To: Ajay Gupta<ajaygupta@example.com>
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::SMTP.start('SMTP_URL') do |smtp|
smtp.send_message 'message', 'ajaygupta@example.com', 'ajaygupta@example.com'
end
Error: when run the above code on heroku console
Net::OpenTimeout: execution expired
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:541:in `initialize'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:541:in `open'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:541:in `tcp_socket'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:551:in `block in do_start'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:550:in `do_start'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:520:in `start'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:457:in `start'
from (irb):3
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from /app/bin/rails:4:in `require'
from /app/bin/rails:4:in `<main>'