Skip to content

Commit

Permalink
Add sendmail support based on merb-mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraninja authored and mikel committed Nov 19, 2009
1 parent 6614a51 commit 0c90f00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions lib/mail/configuration.rb
Expand Up @@ -75,6 +75,13 @@ def pop3(*args, &block)
end
set_settings(Mail::POP3, host_array, &block)
end

def sendmail(sendmail_path = nil)
delivery_method :sendmail
set_settings(Mail::Sendmail) do
path sendmail_path
end
end

# Allows you to define the retriever method for mail, defaults to POP3
#
Expand Down
16 changes: 10 additions & 6 deletions lib/mail/network/delivery_methods/sendmail.rb
@@ -1,18 +1,22 @@
module Mail
class Sendmail
include Singleton

def settings(&block)
if block_given?
instance_eval(&block)
end
self
end


def path(value = nil)
value ? @path = value : @path
end

def Sendmail.deliver!(mail)
# To be implemented
Mail.deliveries << mail
IO.popen("#{Mail.defaults.sendmail.path} #{mail.destinations.join(" ")}", "w+") do |io|
io.puts mail.to_s
end
end

end
end
end
5 changes: 5 additions & 0 deletions spec/mail/configuration_spec.rb
Expand Up @@ -25,4 +25,9 @@

end

it "should configure sendmail" do
Mail.defaults { sendmail "/usr/bin/sendmail" }
Mail.defaults.delivery_method.should == Mail::Sendmail
Mail.defaults.sendmail.path.should == "/usr/bin/sendmail"
end
end

0 comments on commit 0c90f00

Please sign in to comment.