Skip to content

Instantly share code, notes, and snippets.

@neilmock
Created February 2, 2009 20:33
Show Gist options
  • Save neilmock/57083 to your computer and use it in GitHub Desktop.
Save neilmock/57083 to your computer and use it in GitHub Desktop.
def self.transport_via_smtp(tmail, options={})
o = options[:smtp] || {}
smtp = Net::SMTP.new(o[:host], o[:port])
smtp.start(o[:domain], o[:user], o[:password], o[:auth])
smtp.send_message tmail.to_s, tmail.from, tmail.to
smtp.finish
end
require File.dirname(__FILE__) + '/base'
describe Pony do
describe "transport" do
it "transports mail via Net::SMTP using specified server" do
o = {:smtp => {:host => 'localhost', :port => '25', :domain => 'localhost.localdomain', :user => 'user', :password => 'password', :auth => 'plain'}}
smtp = mock('net::smtp object')
Net::SMTP.should_receive(:new).with('localhost', '25').and_return(smtp)
smtp.should_receive(:start).with('localhost.localdomain', 'user', 'password', 'plain')
smtp.should_receive(:send_message).with('message', 'from', 'to')
smtp.should_receive(:finish)
Pony.transport_via_smtp(mock('tmail', :to => 'to', :from => 'from', :to_s => 'message'), o)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment