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
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/spigit_ops/utils.rb', line 30
def self.send_email(options = {})
type = { text: "text/plain", html: "text/html" }
host = options[:host] ? options[:host] : "localhost"
from = options[:from] ? options[:from] : "[email protected]"
to = options[:to] ? options[:to] : "[email protected]"
subject = options[:subject] ? options[:subject] : raise("Must declare a subject for email")
message = options[:message] ? options[:message] : raise("Must declare a message for email")
format = options[:format] ? options[:format] : "text"
content_type = type.has_key?(format.to_sym) ? type[format.to_sym] : type["text"]
if Array === to
= to.join(', ')
elsif String === to
= to
else
= to
end
message = <<MESSAGE_END
From: #{from}
To: #{}
Subject: #{subject}
Mime-Version: 1.0
Content-Type: #{content_type}
Content-Disposition: inline
#{message}
MESSAGE_END
Net::SMTP.start(host, 25) do |smtp|
smtp.send_message message, from, to
end
end
|