The post discusses the use of uuencode to send mails with attachments using mailx command. uuencode can also be used to sent multiple attachments.
1. Example using one attachment
The syntax of uuencode command is :
# uuencode [path of file to be encoded] [file to encode] >> [uuencoded filename]
For example if you have a file named my_file in directory /var/tmp, use the command as :
# uuencode /var/tmp my_file >> my_attachment # mailx -s "This is a mial with only one attachment" email@example.com < my_attachment
The first line encodes the file “my_file” and creates the file “my_attachment”. The second line uses mailx to send the file “my_attachment” to firstname.lastname@example.org with a subject line of “This is a mail with only one attachment”.
2. Example using 2 attached files
# uuencode /var/tmp my_file01 >> multi_attachment # uuencode /var/tmp my_file02 >> multi_attachment # mailx -s "Mail with multiple attachment" email@example.com < multi_attachment
The first line encodes the file “my_file01” and creates the file “multi_attachment”. The second line encodes the file “my_file02” and appends the encoded data to the file “multi_attachment”. The third line sends the encoded file “multi_attachment” to the user.
3. Using uudecode
mailx is a text-based mail agent. It does not contain the MIME (“Multipurpose Internet Mail Extensions”) standard. Examples 1 and 2 use the uuencode command to encode the file. Most modern mail user agent (MUA) used to receive the messages will recognize and decode the files automatically. If the mailx message and uuencoded attachment is received by mailx (or similar non-MIME MUA), then use uudecode to retrieve them:
# uudecode multi_attachment
Linux / UNIX : Send mail with attachment using mutt