【问题标题】:Not able to send eamil from heroku console无法从 heroku 控制台发送电子邮件
【发布时间】:2015-12-29 10:15:50
【问题描述】:

我正在尝试使用SMTPheroku run rails console 上的服务器发送电子邮件,但出现了一些错误。但它在本地系统上运行得非常好,无法理解问题所在。

代码:

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

错误:在heroku控制台上运行上述代码时

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>'

【问题讨论】:

标签: ruby-on-rails heroku


【解决方案1】:

根据您的电话heroku run rails console 显示,您正试图在基于 Heroku 的服务器上运行它。根据 Heroku 自己的docs,您只能使用外部服务发送电子邮件,例如SendGrid 或其他提供商。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 2021-03-13
    • 2015-03-05
    • 1970-01-01
    • 2015-03-24
    • 2012-03-08
    相关资源
    最近更新 更多