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
|
# File 'lib/lita/email_job.rb', line 7
def perform(payload)
redis = payload[:redis]
config = payload[:config]
email_body = build_email_body_from_redis(redis)
options = { address: config.address,
port: config.port,
domain: config.domain,
user_name: config.user_name,
password: config.password,
authentication: config.authentication,
enable_starttls_auto: config.enable_starttls_auto}
Mail.defaults do
ENV['MODE'] == 'test' ? dev_meth = ENV['MODE'] : dev_meth = :smtp
delivery_method(dev_meth , options)
end
if config.email_subject_line == "Standup summary for --today--"
subject_line = config.email_subject_line.gsub(/--today--/, Time.now.strftime('%m/%d'))
else
subject_line = config.email_subject_line
end
mail = Mail.new do
from config.robot_email_address
to config.summary_email_recipients
subject subject_line
body "#{email_body}"
end
if mail.deliver!
Lita.logger.info("Sent standup email to #{mail.to} at #{Time.now}")
redis.keys.each{ |key| redis.del(key) }
end
end
|