Class: LucaSupport::Mail
Instance Method Summary
collapse
included, #load_config, #where
Methods included from Code
decimalize, decode_date, decode_id, decode_month, decode_term, decode_txid, delimit_num, encode_date, encode_dirname, encode_month, encode_term, encode_txid, has_status?, issue_random_id, keys_stringify, match_score, parse_current, readable, take_current, take_history, to_ngram
Constructor Details
#initialize(mail = nil, pjdir = nil) ⇒ Mail
Returns a new instance of Mail.
9
10
11
12
13
14
15
|
# File 'lib/luca_support/mail.rb', line 9
def initialize(mail=nil, pjdir=nil)
@pjdir = pjdir || Dir.pwd
@config = load_config( Pathname(@pjdir) + "config.yml" )
@mail = mail
set_message_default
@host = set_host
end
|
Instance Method Details
#deliver ⇒ Object
17
18
19
20
21
|
# File 'lib/luca_support/mail.rb', line 17
def deliver
@mail.delivery_method(:smtp, @host)
@mail.deliver
end
|
#mail_config(attr = nil) ⇒ Object
34
35
36
37
|
# File 'lib/luca_support/mail.rb', line 34
def mail_config(attr=nil)
return nil if attr.nil?
@config.dig("mail", attr)
end
|
#set_host ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/luca_support/mail.rb', line 23
def set_host
{
authentication: :plain,
address: mail_config("address"),
port: mail_config("port"),
doomain: mail_config("domain"),
user_name: mail_config("user_name"),
password: mail_config("password")
}
end
|
#set_message_default ⇒ Object
39
40
41
42
|
# File 'lib/luca_support/mail.rb', line 39
def set_message_default
@mail.from ||= @config.dig("mail", "from")
@mail.cc ||= @config.dig("mail", "cc")
end
|