Module: Irgat::Mail

Included in:
Irgat
Defined in:
lib/irgat/mail.rb

Instance Method Summary collapse

Instance Method Details

#send_email(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/irgat/mail.rb', line 6

def send_email(options = {})
  mail = build_email(options)
  
  case @config[:smtp_mode]
    when 'smtp'
      Net::SMTP.start(self.config[:smtp_values]["server"],
                      self.config[:smtp_values]["port"],
                      self.config[:smtp_values]["server"],
                      self.config[:smtp_values]["user"],
                      self.config[:smtp_values]["password"],
                      :login) do |smtp|
          smtp.send_mail mail.encoded,
          "irgat@#{ @config[:server_domain] }",
          mail.destinations
      end
    when 'sendmail'
      #send email to localhost without authentication
      Net::SMTP.start('localhost', 25) do |smtp|
          smtp.send_mail mail.encoded,
          "irgat@#{ @config[:server_domain] }",
          mail.destinations
      end
  end
end