Class: Roma::Watch::Mailer

Inherits:
Object
  • Object
show all
Defined in:
lib/roma/tools/roma_watcher.rb

Constant Summary collapse

MAILER =
'/usr/lib/sendmail'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, mailer = nil) ⇒ Mailer

Returns a new instance of Mailer.



25
26
27
28
29
30
# File 'lib/roma/tools/roma_watcher.rb', line 25

def initialize(from, to, mailer = nil)
  @from = from
  @to = to
  @mailer = mailer
  @mailer ||= MAILER
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



21
22
23
# File 'lib/roma/tools/roma_watcher.rb', line 21

def from
  @from
end

#mailerObject (readonly)

Returns the value of attribute mailer.



23
24
25
# File 'lib/roma/tools/roma_watcher.rb', line 23

def mailer
  @mailer
end

#toObject (readonly)

Returns the value of attribute to.



22
23
24
# File 'lib/roma/tools/roma_watcher.rb', line 22

def to
  @to
end

Instance Method Details

#send_mail(sub, msg) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roma/tools/roma_watcher.rb', line 32

def send_mail(sub, msg)
  open("| #{@mailer} -f #{@from} -t", 'w') do |f|
    f.puts "From: #{@from}"
    f.puts "To: #{@to}"
    #f.puts "Subject: #{sub.tojis}"
    f.puts "Subject: #{sub}"
    f.puts "Reply-To: #{@from}"
    f.puts
    f.puts msg.tojis
    2.times{ f.puts }
    f.puts "."
  end
end