A Linux mail command tip

If you're ever working on a Unix or Linux system, and need to email a file to someone else, it may be helpful to know that you can send your email message right from the Unix command line. You don't need to hop into mutt or any other Unix or Linux mail client to email the file.

Here's a simple one-line example where I use the Unix/Linux mail command to email a file to the email address "kim@example.com". In this example, the subject of the message is "Some important information", and the file I'm attaching is named ImportantFile.txt:

mail -s "Some important information" kim@example.com < ImportantFile.txt

Assuming all your email plumbing infrastructure is set up properly, the email message will appear to the recipient as though it came from your current user account on the Unix or Linux system you're sending the message from. If your email infrastructure isn't set up right ... I suppose that's a subject for a much longer tutorial, lol.



mail attachment files using:

mutt -s "subject" -a *file to be sent* email@yahoo.com < msgfile.txt

i tryed send me a e-mail with thit program and still i am
waiting it.

does it work with hotmail.com
*my e-mail: example.exa_examaple@hotmail.com
i think because this character: _

linuxOS@caza:~/Desktop$mail -s "something" example.nove_example@hotmail.com < some.txt


# apt-get install nail

Description: feature-rich BSD mail(1)
This dummy package is provided to provide a smooth upgrade path from
nail to heirloom-mailx. It only contains symlinks to the
heirloom-mailx binary and manpage.
Homepage: http://heirloom.sourceforge.net/mailx.html

INET=`ifconfig | grep 'inet addr' | head -n1`
IP="${INET%%  Bcast*}";IP="${IP##*:}"
NETBIOS_NAME=`uname -n`


# Email from
EMAIL_FROM="Server Name - $IP<$NETBIOS_NAME@example.br>"

# Mail Admin

TMP_TXT=`mktemp /tmp/mirror-txt.XXXXXXXXXX` || exit 1


mail -S ${SMTP} -s "Subject Message" -r "${EMAIL_FROM}" "${MAIL_ADM}" < ${TMP_TXT}

On the Hotmail question, yes, this should work fine with Hotmail. This just uses the plain old mail system, so if Hotmail isn't showing it, perhaps it ended up in a spam folder?

Regarding the Linux nail package, cool, I haven't used it, but I'll check it out.