Class: WCC::SmtpMailer
- Inherits:
-
Object
- Object
- WCC::SmtpMailer
- Defined in:
- lib/wcc/mail.rb
Overview
SmtpMailer is a specific implementation of an mail deliverer that does plain SMTP to host:port using [Net::SMTP].
Instance Method Summary collapse
-
#initialize(host, port) ⇒ SmtpMailer
constructor
A new instance of SmtpMailer.
- #send(data, template, from, tos = []) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ SmtpMailer
Returns a new instance of SmtpMailer.
43 44 45 46 |
# File 'lib/wcc/mail.rb', line 43 def initialize(host, port) @host = host @port = port end |
Instance Method Details
#send(data, template, from, tos = []) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/wcc/mail.rb', line 48 def send(data, template, from, tos = []) Net::SMTP.start(@host, @port) do |smtp| tos.each do |to| # eval ERB msg = template.result(binding) smtp.(msg, from.address, to.address) end end rescue WCC.logger.fatal "Cannot send mails via SMTP to #{@host}:#{@port} : #{$!.to_s}" end |