Saturday, January 4, 2014

Unix/Linux mail commands

While working on a unix based application, I used uuencode command to send mails with attachments. This also helps in avoiding FTP for small files

Below is the command:
uuencode $ATTFILE $ATTFILE | mail -s "$SUBJECT" $MAILTO

Here 
$ATTFILE is the full file name with extension
$SUBJECT is what we want to see in the subject of the mail
$MAILTO is the TO mail address

When I tried the same command to send mail in a Linux machine, it gave junk values. So, I used mutt command. Below is the syntax:

mutt -s $SUBJECT $MAILTO -a $ATTFILE1 $ATTFILE2 < mail_body.txt

$ATTFILE is the full file name with extension
$SUBJECT is what we want to see in the subject of the mail
$MAILTO is the TO mail address
mail_body.txt is what we want to see in the email body

No comments:

Post a Comment