Module: DohEmail
- Defined in:
- lib/doh/util/email.rb
Constant Summary collapse
- @@mail_server =
DohApp::config['mail_server'] || 'mail.' + DohApp::get_required_config_value('domain_name', 'mail_server or domain_name required for mail server')
- @@from_address =
DohApp::config['from_address'] || 'admin@' + DohApp::get_required_config_value('domain_name', 'from_address or domain_name required for notification email address')
- @@smtp_port =
DohApp::config['smtp_port'] || 25
Class Method Summary collapse
Class Method Details
.send_email(subject, body, recipients, from_address = @@from_address) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/doh/util/email.rb', line 8 def self.send_email(subject, body, recipients, from_address = @@from_address) msg = "Subject:#{subject}\nFrom:#{from_address}\nTo:#{recipients.join(', ')}\nContent-Type: text/plain\n\n#{body}" Net::SMTP.start(@@mail_server, @@smtp_port) do |smtp| begin smtp.(msg, from_address, recipients) rescue Exception => excpt Doh::log.warn("got exception while sending email: #{excpt.inspect}") end end end |