Class: Supporter::Mailer

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewlette/mail.rb

Instance Method Summary collapse

Instance Method Details

#send_email(to, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/reviewlette/mail.rb', line 6

def send_email(to,opts={})
  opts[:server]      ||= 'localhost'
  opts[:from]        ||= '[email protected]'
  opts[:from_alias]  ||= 'Reviewlette'
  opts[:subject]     ||= "Commanding Officer of the Week"
  opts[:body]        ||= ""

msg = "From: \#{opts[:from_alias]} <\#{opts[:from]}>\nTo: <\#{to}>\nSubject: \#{opts[:subject]}\n\#{opts[:body]}\n"

  Net::SMTP.start(opts[:server]) do |smtp|
    smtp.send_message msg, opts[:from], to
  end
end