Email

Send backup reports as email

The email notifier allows you to receive a report on success or failure of each of your backup jobs. It uses the Mail library thus supports several delivery methods (namely SMTP, sendmail and exim) to deliver the backup reports.

Common options

OptionDescription
fromThe sender's email addressRequired: yes
toThe recipient's email addressRequired: yes
usingThe delivery method, see belowRequired: yes
withThe delivery settings, see belowRequired: no

You'll likely want to Specify default values globally for email notifications.

SMTP

Sending through a local STMP server does not require any specific setup. You only have to provide the sender's and recipient's addresses.

job "my-project" do
  ...
  notify via: 'email',
  	from: "[email protected]",
  	to: "[email protected]",
  	using: "smtp"
end

SMTP delivery settings

SMTP settings can be specified by providing to the with option an hash of settings:

job "my-project" do
  ...
  notify via: 'email',
  	from: "[email protected]",
  	to: "[email protected]",
  	using: "smtp",
  	with: {
      address: "smtp.example.com",
      user_name: "user",
      password: "secret"
    }
end
SettingDescription
addressThe hostname or IP address of the SMTP serverDefaults to: localhost
portThe port number the SMTP server listens to.Defaults to: 25
domainThe HELO domain (the host to send the message from).Defaults to: localhost.localdomain
user_nameThe username to use for authentication
passwordThe password to use for authentication
authenticationThe authentication methodOne of: plain, login or cram_md5
enable_starttls_autoIndicates whether the notifier should create an initial connection to the SMTP server, then upgrade it to enable encryptionDefaults to: true
sslIndicates whether the notifier should directly try to connect using an SSL connectionDefaults to: false
tlsIndicates whether the notifier should directly try to connect using a TLS connectionDefaults to: false

Common configurations

job "my-project" do
  ...
  notify via: "email",
    from: "[email protected]",
    to: "[email protected]",
    using: "smtp", with: {
      address: "smtp.gmail.com",
      domain: "your.hostname.com",
      port: 587,
      user_name: "gmail-username",
      password: "gmail-password",
      authentication: "plain",
      enable_starttls_auto: true
    }
end
project "my-project" do
  ...
  notify via: "email",
    from: "[email protected]",
    to: "[email protected]",
    using: "smtp", with: {
      address: "smtp.sendgrid.net",
      domain: "your.hostname.com",
      port: 25, # 587 and 2525 also supported with STARTTLS
      user_name: "sendgrid-username",
      password: "sendgrid-password",
      authentication: "plain",
      enable_starttls_auto: true
    }
end
project "my-project" do
  ...
  notify via: "email",
    from: "[email protected]",
    to: "[email protected]",
    using: "smtp", with: {
      address: "smtp.mandrillapp.com",
      domain: "your.hostname.com",
      port: 25, # 587 and 2525 also supported with STARTTLS
      user_name: "mandrill-username",
      password: "mandrill-password",
      authentication: "login",
      enable_starttls_auto: true
    }
end

Sendmail

This delivery method requires the sendmail binary to be present. It usually resides in /usr/sbin/sendmail and is provided by the Sendmail or Postfix packages. A lightweight alternative is SSMTP which redirects calls to sendmail to an external SMTP server.

The notifier assumes the Sendmail program is properly configured.

OptionDescription
locationThe absolute path to the sendmail programRequired: no
project "my-project" do
  ...
  notify via: "email",
    from: "[email protected]",
    to: "[email protected]",
  	using: "sendmail", with: {
      # Optional, the default location usually does the job
      location: "/path/to/sendmail"
    }
end

Exim

This delivery method requires the exim binary to be present. It usually resides in /usr/sbin/exim and is provided by the Exim4 package.

The notifier assumes the Exim program is properly configured.

OptionDescription
locationThe absolute path to the exim programRequired: no
project "my-project" do
  ...
  notify via: "email",
    from: "[email protected]",
    to: "[email protected]",
    using: "exim", with: {
      # Optional, the default location usually does the job
      location: "/path/to/exim"
    }
end