lib/subtrigger/email.rb in subtrigger-0.2.0 vs lib/subtrigger/email.rb in subtrigger-0.2.1

- old
+ new

@@ -15,26 +15,27 @@ # If +sendmail+ can not be found on your system an exception will be raised. #-- # TODO: Use a hash of options rather than plain arguments. class Email attr_accessor :from, :to, :subject, :body, :development + attr_reader :sendmail # Sets up a new message and tries to find +sendmail+ on your system. def initialize(options = {}) @to = options[:to] @from = options[:from] @subject = options[:subject] @body = options[:body] @development = options[:development] || false - @sendmail = `which sendmail`.strip + @sendmail = Subtrigger.sendmail || `which sendmail`.strip raise 'Could not find sendmail; aborting.' if @sendmail.nil? end # Tries to use +sendmail+ to send the message. def send message = header + "\n" + body unless development - fd = open("|#{@sendmail} #{@to}", "w") + fd = open("|#{sendmail} #{to}", "w") fd.print(message) fd.close end message end \ No newline at end of file