forked from foca/integrity-email
/
email.rb
54 lines (45 loc) · 1.14 KB
/
email.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'rubygems'
require 'integrity'
require 'diddies/mailer'
module Integrity
class Notifier
class Email < Notifier::Base
attr_reader :to, :from
def self.to_haml
File.read File.dirname(__FILE__) / "config.haml"
end
def initialize(build, config={})
@to = config.delete("to")
@from = config.delete("from")
super
configure_mailer
end
def deliver!
email.deliver!
end
def email
@email ||= Sinatra::Mailer::Email.new(
:to => to,
:from => from,
:text => body,
:subject => subject
)
end
def subject
"[Integrity] #{build.project.name}: #{short_message}"
end
alias :body :full_message
private
def configure_mailer
Sinatra::Mailer.delivery_method = "net_smtp"
Sinatra::Mailer.config = {
:host => @config["host"],
:port => @config["port"],
:user => @config["user"],
:pass => @config["pass"],
:auth => @config["auth"]
}
end
end
end
end