Module: MailSender

Defined in:
lib/xmltv/xmltv.rb

Class Method Summary collapse

Class Method Details

.linuxmail(to, subj, body) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/xmltv/xmltv.rb', line 22

def linuxmail(to, subj, body)
  from = `/usr/bin/id --name --user`.chomp
  header = ["To: #{to}", "From: #{from}", "Subject: #{subj}"].join("\n")
  mess = [header,"", body].join("\n")
  puts mess
  IO.popen("/usr/sbin/sendmail -t", 'w') do |h|
    h.puts mess
  end
end

.sendmail(*args) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/xmltv/xmltv.rb', line 31

def sendmail(*args)
  if test(?x, '/usr/sbin/sendmail')
    linuxmail(*args)
  else
    raise "FIXME: Don't know how to send mail"
  end
end