I am having trouble getting pony to work. Right now I am getting an error:

TypeError: wrong argument (NilClass)! (Expected kind of OpenSSL::SSL:SSLContext)

I am using Pony.rb with smtp and here is the method call so far:

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

I've searched through the docs and the smtp.rb file to figure out what's going on but somehow it's not being passed an SSLContext object and I'm not sure how to do that in Pony.

有帮助吗?

解决方案

Just figured out the answer. It was to turn off the SSL verification like so:

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

setting the starttls_auto to false and the ssl verify mode to verify none creates an smtp email without the ssl verification.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top