Skip to content

Commit

Permalink
smtp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wiggins committed Jan 14, 2009
1 parent 52f9e76 commit 925f1e8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/pony.rb
Expand Up @@ -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.