If you’ve ever tried sending email via the command line, using the mail utility, you may find that the method can be unreliable in some cases. The email messages are often intercepted by spam bots, filtered by security programs, etc. A more elegant and stable alternative, is to use your existing email server to send the message. Using the program nail makes this an easy task to do via the command line.
The following example shows you how to send a simple message with attachment. Here is the syntax for sending a message with nail.
echo "" | nail -s "" -a ...
In order for nail to function, you must have the .mail configuration file in your path. Here is a sample .mail configuration file to get you started quickly.
set smtp=smtp://yourhost.com
set from="yourname@yourhost.com (Display Name)"
set smtp-auth=login
set smtp-auth-user=your_username
set smtp-auth-password=your_password