SendEmail - the best option for emails on Linux

After any automation or scripting task is complete, I am sure some of them would need to email the output or alert to your mailbox.

Linux does provide a few basic tools/utilities to cater to that requirement such as mailx or sendmail. However, their capabilities are limited to sending emails in text. But the need of the hour, if I may say so, is to have formatted emails with tables, highlighting and underlining words, attachments, the whole shebang!

In other words, emails should be sent in HTML format which can have all these features and much more. 

Though there are methods available to send emails using sendmail or mailx (using uuencode etc.,) they are quite cumbersome and convoluted.

That's where "sendemail" utility comes in. It can send html emails so easily and with attachments as well.

The software is described as "a lightweight tool written in Perl for sending SMTP email from the console".

Some flavours of Linux provide it as a package (like Ubuntu, Kali Linux etc.).

Download it from here or here.

It's a simple utility with easily understandable options but you can read more on sendemail from Kali Linux and Ubuntu.

 


$ ./sendEmail

sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net>

Synopsis:  sendEmail -f ADDRESS [options]

  Required:
    -f ADDRESS                from (sender) email address
    * At least one recipient required via -t, -cc, or -bcc
    * Message body required via -m, STDIN, or -o message-file=FILE

  Common:
    -t ADDRESS [ADDR ...]     to email address(es)
    -u SUBJECT                message subject
    -m MESSAGE                message body
    -s SERVER[:PORT]          smtp mail relay, default is localhost:25

  Optional:
    -a   FILE [FILE ...]      file attachment(s)
    -cc  ADDRESS [ADDR ...]   cc  email address(es)
    -bcc ADDRESS [ADDR ...]   bcc email address(es)
    -xu  USERNAME             username for SMTP authentication
    -xp  PASSWORD             password for SMTP authentication

  Paranormal:
    -b BINDADDR[:PORT]        local host bind address
    -l LOGFILE                log to the specified file
    -v                        verbosity, use multiple times for greater effect
    -q                        be quiet (i.e. no STDOUT output)
    -o NAME=VALUE             advanced options, for details try: --help misc
        -o message-content-type=<auto|text|html>
        -o message-file=FILE         -o message-format=raw
        -o message-header=HEADER     -o message-charset=CHARSET
        -o reply-to=ADDRESS          -o timeout=SECONDS
        -o username=USERNAME         -o password=PASSWORD
        -o tls=<auto|yes|no>         -o fqdn=FQDN


  Help:
    --help                    the helpful overview you're reading now
    --help addressing         explain addressing and related options
    --help message            explain message body input and related options
    --help networking         explain -s, -b, etc
    --help output             explain logging and other output options
    --help misc               explain -o options, TLS, SMTP auth, and more


Some of the options:

TEXT EMAIL

sendEmail -t "<TO_EMAIL>" -f "<FROM>" -u "<SUBJECT>" [-cc "<EMAIL_IN_CC>" -bcc "<EMAIL_IN_BCC>"] -o message-file="<INPUT_FILE_NAME>"

OR

sendEmail -t "<TO_EMAIL>" -f "<FROM>" -u "<SUBJECT>" [-cc "<EMAIL_IN_CC>" -bcc "<EMAIL_IN_BCC>"] -m "<MESSAGE_BODY>"

HTML EMAIL (FORMATTED EMAIL)

sendEmail -t "<TO_EMAIL>" -f "<FROM>" -u "<SUBJECT>" [-cc "<EMAIL_IN_CC>" -bcc "<EMAIL_IN_BCC>"] -o message-content-type=html -o message-file="<INPUT_HTML_FILE_NAME>"

HTML EMAIL WITH ATTACHMENTS
 

sendEmail -t "<TO_EMAIL>" -f "<FROM>" -u "<SUBJECT>" [-cc "<EMAIL_IN_CC>" -bcc "<EMAIL_IN_BCC>"] -o message-content-type=html -o message-file="<INPUT_FILE_NAME>" -a "<FILE_TO_BE_ATTACHED>"


Well, happy emailing!


Comments

Popular posts from this blog

java.lang.ExceptionInInitializerError while trying to Access login page

Solution to "End Program - WMS Idle"

WGET shell Script for downloading patches