【问题标题】:Ruby Pony emails ssl issueRuby Pony 发送 ssl 问题
【发布时间】:2013-06-19 17:51:38
【问题描述】:

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

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 中做到这一点。

【问题讨论】:

    标签: ruby email pony


    【解决方案1】:

    刚刚找到答案。就像这样关闭 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 电子邮件。

    【讨论】:

    • 是的,使用 SMTP SSL 垃圾邮件真是太棒了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    相关资源
    最近更新 更多