2

我很难让小马上班。现在我收到一个错误:

TypeError:错误的参数(NilClass)!(预期类型的​​ OpenSSL::SSL:SSLContext)

我正在使用 Pony.rb 和 smtp,这是迄今为止的方法调用:

class Email
     def send_email
             Pony.mail({
                   :to => 'user@domain.com',
                   :via => :smtp,
                   :via_options => {
                         :address => 'smtp.macpractice.com',
                         :port => '587', 
                         :enable_starttls_auto => true,
                         :user_name => 'user@macpractice.com',
                         :password => 'password',
                         :authentication => :plain,
                         :domain => "localhost.localdomain"
                   }
             })
     end
end

我已经搜索了文档和 smtp.rb 文件以弄清楚发生了什么,但不知何故它没有被传递一个 SSLContext 对象,我不知道如何在 Pony 中做到这一点。

4

1 回答 1

3

才想出答案。就像这样关闭 SSL 验证:

require 'pony'
class Email
    def send_email 
            Pony.mail({
                    :to => 'cole@macpractice.com',
                    :from => 'blaine@macpractice.com',
                    :subject => 'test',
                    :body => "yo dude",
                    :via => :smtp,      
                    :via_options => {
                            :address        => 'smtp.macpractice.com',
                            :port           => '10040',
                            :user_name      => 'blaine',
                            :password       => '',
                            :authentication => :cram_md5,
                            :domain         => "localhost.localdomain",
                            :openssl_verify_mode    => OpenSSL::SSL::VERIFY_NONE,
                            :enable_starttls_auto   => false

                    }   
            })
    end
end

将 starttls_auto 设置为 false 并将 ssl 验证模式设置为验证 none 会创建没有 ssl 验证的 smtp 电子邮件。

于 2013-06-21T14:40:29.597 回答