Simple Ruby email out localhost:25, no OpenSSL::SSL::SSLError, no tlsconnect error

  1. This skips the common OpenSSL::SSL::SSLError / tlscommon errors somehow, see below for error output.
  2. DON'T use pony's "smtp" hash option, it has the same problem. Notice it is missing here!
  1. gem install pony
  2. take below code 
    1. put in ~/bin/mail_test.rb
    2. tweak for your environment
    3. chmod +x ~/bin/mail_test.rb


require 'rubygems'
require 'pony'

mystring = "a\nb\nc"

Pony.mail(:to => '', :from => '', :subject => 'Test mail script', :body => 'Hello there.', :attachments => {"mail_test.txt" =>"/home/me/bin/mail_test.rb"), "mystring.txt" => mystring})

Common, irritating tlscommon error:

/usr/lib/ruby/1.8/openssl/ssl-internal.rb:123:in `post_connection_check': hostname was not match with the server certificate (OpenSSL::SSL::SSLError)
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/mail-2.5.3/lib/mail/core_extensions/smtp.rb:17:in `tlsconnect'
from /usr/lib/ruby/1.8/net/smtp.rb:562:in `do_start'
from /usr/lib/ruby/1.8/net/smtp.rb:525:in `start'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/mail-2.5.3/lib/mail/network/delivery_methods/smtp.rb:136:in `deliver!'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/mail-2.5.3/lib/mail/message.rb:245:in `deliver!'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/pony-1.4/lib/pony.rb:166:in `deliver'
from /usr/lib/rvm/gems/ruby-1.9.3-p194/gems/pony-1.4/lib/pony.rb:138:in `mail'


Popular posts from this blog

Debugging pfsense firewall rules clearly and easily

Direct ssh to a server via proxy using putty/plink on Windows

telnet vs netcat