Class: Tzispa::Utils::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/tzispa/utils/mail.rb

Constant Summary collapse

DEFAULT_CHARSET =
'UTF-8'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, logger = nil) ⇒ Mail

Returns a new instance of Mail.



16
17
18
19
20
21
22
23
24
# File 'lib/tzispa/utils/mail.rb', line 16

def initialize(config, logger = nil)
  @hmtl = false
  @debug = false
  @charset = DEFAULT_CHARSET
  @logger = logger
  @config = config
  smtp_configuration(config)
  @mail = ::Mail.new
end

Instance Attribute Details

#ccObject

Returns the value of attribute cc.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def cc
  @cc
end

#charsetObject

Returns the value of attribute charset.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def charset
  @charset
end

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/tzispa/utils/mail.rb', line 12

def config
  @config
end

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def content
  @content
end

#debugObject

Returns the value of attribute debug.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def debug
  @debug
end

#fromObject

Returns the value of attribute from.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def from
  @from
end

#htmlObject

Returns the value of attribute html.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def html
  @html
end

#loggerObject (readonly)

Returns the value of attribute logger.



12
13
14
# File 'lib/tzispa/utils/mail.rb', line 12

def logger
  @logger
end

#mailObject (readonly)

Returns the value of attribute mail.



12
13
14
# File 'lib/tzispa/utils/mail.rb', line 12

def mail
  @mail
end

#subjectObject

Returns the value of attribute subject.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def subject
  @subject
end

#toObject

Returns the value of attribute to.



9
10
11
# File 'lib/tzispa/utils/mail.rb', line 9

def to
  @to
end

Instance Method Details

#add_file(path, attach_name) ⇒ Object



36
37
38
# File 'lib/tzispa/utils/mail.rb', line 36

def add_file(path, attach_name)
  mail.attachments[attach_name] = File.read(path)
end

#send_mailObject



26
27
28
29
30
31
32
33
34
# File 'lib/tzispa/utils/mail.rb', line 26

def send_mail
  recipients
  body
  mail.subject = subject
  mail.charset = charset
  mail.deliver
rescue
  raise if debug
end