Created
January 20, 2012 18:04
-
-
Save sam/1648719 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Harbor | |
module MailServers | |
class Sendmail < Abstract | |
attr_accessor :filter | |
def initialize(config = {}) | |
@sendmail = config[:sendmail] || `which sendmail`.chomp | |
@filter = config[:delivery_address_filter] | |
@sender = config[:sender] || "bounce" | |
end | |
def deliver(message_or_messages) | |
messages = Array === message_or_messages ? message_or_messages : [message_or_messages] | |
messages.each do |message| | |
filter.apply(message) if filter | |
sendmail = ::IO.popen("#{@sendmail} -i -t -f#{@sender}", "w+") | |
sendmail.write(message.to_s) | |
sendmail.close_write | |
sendmail.close_read | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment