- This skips the common OpenSSL::SSL::SSLError / tlscommon errors somehow, see below for error output.
- DON'T use pony's "smtp" hash option, it has the same problem. Notice it is missing here!
- gem install pony
- take below code
- put in ~/bin/mail_test.rb
- tweak for your environment
- chmod +x ~/bin/mail_test.rb
#!/usr/bin/ruby
require 'rubygems'
require 'pony'
mystring = "a\nb\nc"
Pony.mail(:to => 'abc@efg.org', :from => 'me@example.com', :subject => 'Test mail script', :body => 'Hello there.', :attachments => {"mail_test.txt" => File.read("/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'
#!/usr/bin/ruby
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'
No comments:
Post a Comment
Note: only a member of this blog may post a comment.