Method: WCC::MailNotificator#notify!

Defined in:
lib/wcc/mail.rb

#notify!(data) ⇒ Object

Sends a mail built up from some [ERB] templates to the specified adresses.

Parameters:

  • data (Object)

    used to construct ERB binding



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/wcc/mail.rb', line 53

def notify!(data)
  # from/to addresses
  data.from = Conf[:from_mail]
  data.to = @to
  # generate a boundary that may be used for multipart
  data.boundary = "frontier-#{data.site.id}"
  # generate message
  data.bodies = {}
  # eval all body templates
  self.class.get_bodies.each do |name,template|
    data.bodies[name] = template.result(binding)
  end
  # eval main template
  msg = self.class.get_main.result(binding)
  
  case Conf[:mailer]
  when 'smtp'
    self.class.send_smtp(msg, Conf[:from_mail], @to, Conf[:smtp_host], Conf[:smtp_port])
  when 'fake_file'
    self.class.send_fake_file(msg, Conf[:from_mail], @to)
  end
end