class Ring::SQA::Alarm::Email
Constants
- LIST_ID
- SERVER
Public Instance Methods
Source
# File lib/ring/sqa/alarm/email.rb, line 11 def send opts short, long = opts[:short], opts[:long] @from = CFG.email.from @to = [CFG.email.to].flatten prefix = CFG.email.prefix? ? CFG.email.prefix : '' @list_id = CFG.email.list_id? ? CFG.email.list_id : LIST_ID @subject = prefix + short @reply_to = CFG.email.reply_to? ? CFG.email.reply_to : @from @body = long send_email compose_email rescue => error Log.error "Email raised '#{error.class}' with message '#{error.message}'" end
Private Instance Methods
Source
# File lib/ring/sqa/alarm/email.rb, line 27 def compose_email mail = [] mail << 'From: ' + @from mail << 'To: ' + @to.join(', ') mail << 'Reply-To: ' + @reply_to mail << 'Subject: ' + @subject mail << 'List-Id: ' + @list_id mail << 'X-Mailer: ' + 'ring-sqa' mail << '' mail = mail.join("\n") mail+@body end
Source
# File lib/ring/sqa/alarm/email.rb, line 40 def send_email email Net::SMTP.start('localhost') do |smtp| smtp.send_message email, @from, @to end end