-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmailer.rb
46 lines (40 loc) · 965 Bytes
/
mailer.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
require_relative 'mail'
class Mailer
def initialize(summary, rules_with_errors)
@summary = summary
@rules_with_errors = rules_with_errors
end
def admin_email
ENV['URL_CHECKER_MAILER_ADMIN']
end
def prepare_msg
msg = msg_body
msg += "<p>#{@summary}</p>"
if @rules_with_errors.any?
@rules_with_errors.each do |rule|
msg += "<p>#{rule.to_s}</p>"
end
else
msg += "No errors!"
end
msg
end
def send
message = prepare_msg
admin_e = admin_email
Mail.deliver do
to admin_e
from "sender@some.email"
subject 'Url checker report'
html_part do
content_type 'text/html; charset=UTF-8'
body message
end
end
end
def msg_body
<<MESSAGE_END
<h1>Report</h1>
MESSAGE_END
end
end