我尝试通过gmail帐户向Devise发送电子邮件后收到此错误消息
“Net :: SMTP的未定义方法`default_ssl_context”:Class“
这是我的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'
}
你以前见过这个错误吗?感谢
答案 0 :(得分: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