Module: Sendmail

Defined in:
lib/sendmail.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/sendmail.rb', line 3

def args
  @args
end

.binObject

Returns the value of attribute bin.



3
4
5
# File 'lib/sendmail.rb', line 3

def bin
  @bin
end

Class Method Details

.sendmail!(mail, opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sendmail.rb', line 14

def sendmail!(mail, opts = {})
  bin     = opts[:bin]  || Sendmail.bin
  args    = opts[:args] || Sendmail.args
  command = [bin, args]
  command << opts[:to] if opts.key?(:to)
  
  io = IO.popen(command, "w+b")
  io.write(mail)
  io.close
  $?.to_i == 0
end