Sha256: 5b6f5bd57f76c289d25229d161ee6e0e486db3053ba35b552485da1cf5389904

Contents?: true

Size: 869 Bytes

Versions: 6

Compression:

Stored size: 869 Bytes

Contents

require 'net/smtp'

module Ring
class SQA
class Alarm

  class Email
    SERVER = 'localhost'

    def send msg
      @from    = CFG.email.from
      @to      = [CFG.email.to].flatten
      prefix   = CFG.email.prefix? ? CFG.email.prefix : ''
      @subject = prefix + msg[:short]
      @body    = msg[:long]
      send_email compose_email
    end

    private

    def initialize
    end

    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

6 entries across 6 versions & 1 rubygems

Version Path
ring-sqa-0.0.21 lib/ring/sqa/alarm/email.rb
ring-sqa-0.0.20 lib/ring/sqa/alarm/email.rb
ring-sqa-0.0.19 lib/ring/sqa/alarm/email.rb
ring-sqa-0.0.18 lib/ring/sqa/alarm/email.rb
ring-sqa-0.0.16 lib/ring/sqa/alarm/email.rb
ring-sqa-0.0.15 lib/ring/sqa/alarm/email.rb