0

我尝试通过 gmail 帐户使用 Devise 发送电子邮件后收到此错误消息

“Net::SMTP:Class 的未定义方法‘default_ssl_context’”

这是我的 production.rb 环境

require 'net/smtp'
require 'tlsmail'
require 'openssl'

OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true

ActionMailer::Base.smtp_settings = {
  :enable_starttls_auto => true,
  :address            => 'smtp.gmail.com',
  :port               => 587,
  :tls                => true,
  :domain             => 'gmail.com',
  :authentication     => :plain,
  :user_name          => 'myemail@myemail',
  :password           => 'password'

}

你以前见过这个错误吗?谢谢

4

1 回答 1

0

我不确定你为什么有:

require 'net/smtp'
require 'tlsmail'
require 'openssl'

OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)

production.rb应该是这样的:

Portal::Application.configure do

config.cache_classes = true
  config.consider_all_requests_local       = false #Turn to true to get error log
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compress = true
  config.assets.compile = true
  config.assets.digest = true
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify

  #Defined SMTP options
  #SMTP
  config.action_mailer.default_url_options = { :host => 'portal.herokuapp.com' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      :address              => 'smtp.gmail.com',
      :port                 => 587,
      :domain               => 'gmail.com',
      :user_name            => 'email@gmail.com',
      :password             => 'pass',
      :authentication       => 'login',
      :enable_starttls_auto => true
  }
end
于 2013-05-27T12:28:01.140 回答