Permalink
Browse files

smtp fixes

  • Loading branch information...
adamwiggins committed Jan 14, 2009
1 parent 52f9e76 commit 925f1e82e7b2e50d02d0fd7a48d1429008a9beb2
Showing with 6 additions and 12 deletions.
  1. +6 −12 lib/pony.rb
View
@@ -48,25 +48,19 @@ def self.via_options
end
def self.transport_via_sendmail(tmail, options={})
- IO.popen('-') do |pipe|
+ IO.popen('-', 'w+') do |pipe|
if pipe
pipe.write(tmail.to_s)
else
- exec(sendmail_binary, tmail.to)
+ exec(sendmail_binary, *tmail.to)
end
end
end
def self.transport_via_smtp(tmail, options={})
- options = options[:smtp] || {}
-
- # Credits for Sinatra::Mailer
- options_array = options.empty? ? [ 'localhost' ] :
- [options[:host], options[:port].to_i, options[:domain],
- options[:user], options[:pass], options[:auth] ]
-
- Net::SMTP.start(*options_array) do |smtp|
- smtp.sendmail(tmail.to_s, tmail.from, tmail.to)
- end
+ o = options[:smtp] || {}
+ smtp = Net::SMTP.new(o[:host], o[:port])
+ smtp.start(o[:domain], o[:user], o[:password], o[:auth])
+ smtp.finish
end
end

0 comments on commit 925f1e8

Please sign in to comment.