Shell Utilities | amail

CodePin.org



ABOUT

A Mail Client With A Command Line Interface.

This is used to create and send an e-mail from a shell command line, and can be incorporated into other command output with unix pipe. One can pipe text into an e-mail, or easily send e-mail with attachments from the command line. The amail program can even be used in a cron job or batch process in performing tasks that could require something like mailing out the latest log files in the log directory based on the file's last modified date.
It was intended from its creation to be a shell-only program utility.

amail is Open Source and Free to use. It falls under the LICENSE of its parent project.


REQUIREMENTS

The PERL module requirements for executing amail is as follows:

  • Getopt::Std
  • File::Find
  • Env
  • MIME::Lite
  • Net::SSH(sshopen3)
  • Net::SCP
  • File::Basename
View the README for further details.


USAGE
amail - A Mail Client With A Command Line Interface usage: /usr/local/bin/amail [-h] [-m] [opts] [-c] [opts] usage: /usr/local/bin/amail [-m] [-f from@domain] [-t to@domain] [-s "subject text"] [-b "body text" or "-"] [-c] [-d "user@host:/path/to/dest" or "/local/path/dest"] [-r "dirpath:filename-regex:filtername"] [file [file]] -h # This help test -y # test what would happen in retrieving attachments [ mail features ] -m # turn on the mail functionality -f 'u@d.com' # The 'From:' e-mail to be sent from -t 'u@d.com' # The 'To:' e-mail address to send to -s "text msg" # The 'Subject:' text -b "text" or - # The text of the body, or '-' to use <STDIN> standard input [ copy features ] -c # turn on the copy functionality -d 'u@h:/dest/' # either a local or ssh destination directory to copy files to # if you use ssh copy, you must have ssh key authentication setup [ source file features ] -r 'filter' # a regex type filter of '/path/to/dir:filename-regex;filter-name:filter-options' # for attaching, or copying, one or more files [file] # one or more files to attach to this e-mail message, and/or copy [filters] available filters: regex /dir/path:filename-regex;regex:matching-regex-pattern stat size /dir/path:filename-regex;stat:size=[+-=][size in bytes] stat atime /dir/path:filename-regex;stat:atime=[+-=][access time seconds ago] stat ctime /dir/path:filename-regex;stat:ctime=[+-=][creation time seconds ago] stat mtime /dir/path:filename-regex;stat:mtime=[+-=][modification time seconds ago] Examples: # Send a picture of yourself to a friend as an attachment Linux$ /usr/local/bin/amail -f you@dom.com -t friend@dom.com -s "Hello friend" \ -b "This is an e-mail message for my friend" \ photo/pictureOfMe.jpg # pipe text into an e-mail message Linux$ cat /var/log/messages | tail -100 | /usr/local/bin/amail -f me@dom.com \ -s "last 100 lines of messages log on thissys server" \ -t logadmin@thissys.dom.com -b - Linux$ /usr/local/bin/amail -f logadmin@thissys.dom.com -t me@dom.com \ -s "Attached are gziped logfiles smaller than 5000 bytes" -r '/var/logs:server\-message\.log\-\d{7,9}\.gz:stat;size=-5000' Note: Copy [-c] is performed before and instead of mailing [-m]

AVAILABILITY

View the amail README, CHANGES, online.
View the amail Subversion repository online.

You can download the source code from Subversion.