2013-05-27 57 views
0

我收到此錯誤信息後,我嘗試發送與設計的電子郵件,通過Gmail帳戶未定義的方法`default_ssl_context」淨:: SMTP:類

「未定義的方法`default_ssl_context」淨:: SMTP:類」

這是我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   => '[email protected]', 
    :password   => 'password' 

}

你有沒有見過這個錯誤?由於

回答

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 protected]', 
     :password    => 'pass', 
     :authentication  => 'login', 
     :enable_starttls_auto => true 
    } 
end 
+0

謝謝你,但我得到一個超時錯誤;這就是爲什麼我使用了上述設置 - > Timeout :: Error(執行過期): tlsmail(0.0.1)lib/net/smtp.rb:454:in'initialize' tlsmail(0.0.1)lib/net/tlsmail(0.0.1)lib/net/smtp.rb:454:in'block in do_start' tlsmail(0.0.1)lib/net/smtp.rb:454:'open' tlsmail在'do_start' tlsmail(0.0.1)lib/net/smtp.rb:440:'start' mail(2.5.4)lib/mail/network/delivery_methods/smtp.rb:112:在'deliver! 「 –

+0

@Nick_K當你嘗試這個設置時會發生什麼 – David

+0

對不起,我沒有正確解釋我自己。這裏是:當我嘗試我的設置時,我得到了「Net :: SMTP:Class」的「Undefined method'default_ssl_context」。當我嘗試設置時,出現TimeOut錯誤。 –