Sha256: 7e8013e9f7cf63122e3dd7a44a38b0d6e001ab27fe00559de6470b4afe01fd51

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

require 'net/smtp'

module Ring
class SQA
class Alarm

  class Email
    SERVER = 'localhost'

    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 : ''
      @subject = prefix + short
      @body    = long
      send_email compose_email
    rescue => error
      Log.error "Email raised '#{error.class}' with message '#{error.message}'"
    end

    private

    def compose_email
      mail = []
      mail << 'From: '     + @from
      mail << 'To: '       + @to.join(', ')
      mail << 'Subject: '  + @subject
      mail << 'List-Id: '  + 'ring-sqa <sqa.ring.nlnog.net>'
      mail << 'X-Mailer: ' + 'ring-sqa'
      mail << ''
      mail = mail.join("\n")
      mail+@body
    end

    def send_email email
      Net::SMTP.start('localhost') do |smtp|
        smtp.send_message email, @from, @to
      end
    end
  end

end
end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ring-sqa-0.1.11 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.10 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.9 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.8 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.7 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.6 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.5 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.4 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.3 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.2 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.1 lib/ring/sqa/alarm/email.rb
ring-sqa-0.1.0 lib/ring/sqa/alarm/email.rb