Skip to content

Email Notifications

Panagiotis Atmatzidis edited this page Oct 26, 2015 · 4 revisions

Install Gems

To use email notifications install the mail gem:

$ gem install mechanize mail argosnap

If you want to receive HTML emails, install haml too:

$ gem install mechanize mail haml argosnap

Configure

Enable email notifications by changing notifications_email: false to notifications_email: true in the config.yml.

Most smtp settings are self explanatory:

[...]
smtp: {
  email_delivery_method: 'smtp', 
  smtpd_user: 'username',
  smtpd_password: 'password',
  smtpd_address: "gmail.google.com", 
  smtpd_port: 587, 
  smtpd_from: 'user@host.domain.com', 
  smtpd_to: 'your@email.com', 
  format: 'txt'},
[...]

There are two email_delivery_method: options:

  • sendmail - Best option if the host has a properly working MTA.
  • smtp - requires smtpd_user, smtpd_password, smtpd_port, etc.

By default argosnap will try to use the sendmail binary. If you choose to smtp as a delivery method, you need to keep in mind that our SSL settings facilitate users who have their own mail server and self-signed SSL certificates. Argosnap has ssl: true, openssl_verify_mode: 0.

If you need to verify the SSL certificate you must set openssl_verify_mode: 1.

Send Notifications

Let's assume the config.yml looks like this:

    ---
    :email: user@domain.net
    :password: my_super_password
    :threshold: 10
    :seconds: 86400
    :notifications_osx: false
    :notifications_email: true
    :smtp:
      :email_delivery_method: smtp
      :smtpd_user: user@gmail.com
      :smtpd_password: gmail_password
      :smtpd_address: mail.gmail.com
      :smtpd_port: 465
      :smtpd_from: user@gmail.com
      :smtpd_to: alerts@domain.net
      :format: html
    :notifications_pushover: false
    :pushover:
      :key: 
      :token: 

Now we can setup argosnap to run on a cron job:

30 20 * * * argosnap -n notify

This entry means that argosnap will run every day at 20:30 o'clock. Every time argosnap runs, compares the threshold with our tarsnap balance. If current balance falls below the threshold, a mail notification is sent.

There are many guides online about how to use cron.

Clone this wiki locally