Class: Backup::Notifier::Mail

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/notifier/mail.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#max_retries, #model, #on_failure, #on_success, #on_warning, #retry_waitsec

Instance Method Summary collapse

Methods inherited from Base

#perform!

Methods included from Config::Helpers

included

Constructor Details

#initialize(model, &block) ⇒ Mail

Returns a new instance of Mail.



121
122
123
124
125
126
127
# File 'lib/backup/notifier/mail.rb', line 121

def initialize(model, &block)
  super
  instance_eval(&block) if block_given?

  @send_log_on ||= [:warning, :failure]
  @encryption  ||= :starttls
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers

Instance Attribute Details

#addressObject

SMTP Server Address



42
43
44
# File 'lib/backup/notifier/mail.rb', line 42

def address
  @address
end

#authenticationObject

Authentication type

Acceptable values: :plain, :login, :cram_md5



64
65
66
# File 'lib/backup/notifier/mail.rb', line 64

def authentication
  @authentication
end

#delivery_methodObject

Mail delivery method to be used by the Mail gem.

Supported methods:

:smtp - ::Mail::SMTP (default)

Settings used by this method: #address, #port, #domain, #user_name, #password, #authentication, #encryption, #openssl_verify_mode

:sendmail - ::Mail::Sendmail

Settings used by this method: #sendmail_args

:exim - ::Mail::Exim

Settings used by this method: #exim_args

:file - ::Mail::FileDelivery

Settings used by this method: #mail_folder



30
31
32
# File 'lib/backup/notifier/mail.rb', line 30

def delivery_method
  @delivery_method
end

#domainObject

Your domain (if applicable)



50
51
52
# File 'lib/backup/notifier/mail.rb', line 50

def domain
  @domain
end

#encryptionObject

Set the method of encryption to be used for the SMTP connection.

:starttls (default)

Use STARTTLS to upgrade the connection to a SSL/TLS connection.

:tls or :ssl

Use a SSL/TLS connection.

:none

No encryption will be used.



77
78
79
# File 'lib/backup/notifier/mail.rb', line 77

def encryption
  @encryption
end

#exim_argsObject

Optional arguments to pass to ‘exim`

Note that this will override the defaults set by the Mail gem (currently: ‘-i -t’) So, if set here, be sure to set all the arguments you require.

Example: ‘-i -t -X/tmp/traffic.log’



106
107
108
# File 'lib/backup/notifier/mail.rb', line 106

def exim_args
  @exim_args
end

#fromObject

Sender Email Address



34
35
36
# File 'lib/backup/notifier/mail.rb', line 34

def from
  @from
end

#mail_folderObject

Folder where mail will be kept when using the ‘:file` `delivery_method`.

Default location is ‘$HOME/Backup/emails’



112
113
114
# File 'lib/backup/notifier/mail.rb', line 112

def mail_folder
  @mail_folder
end

#openssl_verify_modeObject

OpenSSL Verify Mode

Valid modes: :none, :peer, :client_once, :fail_if_no_peer_cert See OpenSSL::SSL for details.

Use :none for a self-signed and/or wildcard certificate



86
87
88
# File 'lib/backup/notifier/mail.rb', line 86

def openssl_verify_mode
  @openssl_verify_mode
end

#passwordObject

SMTP Server Password (sender email’s credentials)



58
59
60
# File 'lib/backup/notifier/mail.rb', line 58

def password
  @password
end

#portObject

SMTP Server Port



46
47
48
# File 'lib/backup/notifier/mail.rb', line 46

def port
  @port
end

#send_log_onObject

Array of statuses for which the log file should be attached.

Available statuses are: ‘:success`, `:warning` and `:failure`. Default: [:warning, :failure]



119
120
121
# File 'lib/backup/notifier/mail.rb', line 119

def send_log_on
  @send_log_on
end

#sendmail_argsObject

Optional arguments to pass to ‘sendmail`

Note that this will override the defaults set by the Mail gem (currently: ‘-i’). So, if set here, be sure to set all the arguments you require.

Example: ‘-i -X/tmp/traffic.log’



96
97
98
# File 'lib/backup/notifier/mail.rb', line 96

def sendmail_args
  @sendmail_args
end

#toObject

Receiver Email Address



38
39
40
# File 'lib/backup/notifier/mail.rb', line 38

def to
  @to
end

#user_nameObject

SMTP Server Username (sender email’s credentials)



54
55
56
# File 'lib/backup/notifier/mail.rb', line 54

def user_name
  @user_name
end