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, #message, #model, #on_failure, #on_success, #on_warning, #retry_waitsec

Instance Method Summary collapse

Methods inherited from Base

#perform!

Methods included from Config::Helpers

included

Methods included from Utilities::Helpers

#utility_remote

Constructor Details

#initialize(model, &block) ⇒ Mail

Returns a new instance of Mail.



133
134
135
136
137
138
139
# File 'lib/backup/notifier/mail.rb', line 133

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



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

def address
  @address
end

#authenticationObject

Authentication type

Acceptable values: :plain, :login, :cram_md5



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

def authentication
  @authentication
end

#bccObject

BCC receiver Email Address



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

def bcc
  @bcc
end

#ccObject

CC receiver Email Address



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

def cc
  @cc
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)



62
63
64
# File 'lib/backup/notifier/mail.rb', line 62

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.



89
90
91
# File 'lib/backup/notifier/mail.rb', line 89

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’



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

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’



124
125
126
# File 'lib/backup/notifier/mail.rb', line 124

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



98
99
100
# File 'lib/backup/notifier/mail.rb', line 98

def openssl_verify_mode
  @openssl_verify_mode
end

#passwordObject

SMTP Server Password (sender email’s credentials)



70
71
72
# File 'lib/backup/notifier/mail.rb', line 70

def password
  @password
end

#portObject

SMTP Server Port



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

def port
  @port
end

#reply_toObject

Set reply to email address



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

def reply_to
  @reply_to
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]



131
132
133
# File 'lib/backup/notifier/mail.rb', line 131

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’



108
109
110
# File 'lib/backup/notifier/mail.rb', line 108

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)



66
67
68
# File 'lib/backup/notifier/mail.rb', line 66

def user_name
  @user_name
end