maily is designed for batch operations which send notifications via email. Newer versions of the mailx utility contain the same functionality, but older ones do not.

Important features:

  • "-f" flag which allows a From address to be set. "Full Name <username@…>" syntax is allowed.
  • "-mA" flag prevents mail from being sent if body is empty. Used in cron jobs where a notification should only be sent if a command returns output.

Project

Requirements:

  • Perl
  • Mail::Sender

To check out the source code:

svn co https://wush.net/svn/foss/maily/

A  fatpacked binary is also available which will only require Perl to run.

To browse the source online,  click here.

To submit a bug report,  click here.

To view existing bug reports,  click here.

Documentation

Usage:

usage: ./maily recipient [-c cc] [-b bcc] [-f from] [-s subject] [-m message] [-a /path/to/attachment]
                    [-h host] [-p port]

 recipient  - To email address, required
        -c  - Cc email addresses, default empty list
        -b  - Bcc email addresses, default empty list
        -f  - From email address, default user@host
        -s  - Email subject, default '(untitled)'
        -m  - Message body, '-' to read from STDIN, default '-'
        -mA - abort if message is empty or contains only whitespace
        -mE - enable iterpolation of newlines in message body
        -a  - Path to file attachment, '-' to read from STDIN, default null
              If set to '-', -m parameter is required
        -h  - SMTP server hostname, default localhost
        -p  - SMTP server port, default 25

For example, if you would like to be emailed when your 3ware controller has degraded arrays:

    tw_cli /c0/u0 show | grep RAID | grep -v OK | maily recipient@example.com -s "`hostname` - raid event" -f "My Monitoring <sender@example.com>" -mA