Friday, August 8, 2008

sending multiple attachments using Unix mailx command

Hi, ever tried to send mail from unix command prompt that contains multiple files as attachments, here is how you can do it in just a single command.

(uuencode file1.oldname file1.newname; uuencode file2.oldname file2.newname;
uuencode file3.oldname file3.newname; uuencode file4.oldname file4.newname) |
mailx -s "Subject of the mail" xyz@abc.com


Above snippets sends the file1, file2, file3 and file4 to the xyz@abc.com as attachments in a mail with a subject "Subject of the mail".

I have used a uuencode command that takes files as input and encode them over the network. The file1.oldname appears as file1.newname to the receiver when he/she opens the attachment.

You can send single file as an attachment as follows

mail -s "Subject of the mail" xyz@abc.com < file1

Sphere: Related Content

4 comments:

Anonymous said...

Thanks a lot !!

Anonymous said...

This was very help. Thanks.

Unknown said...

worked! thanks :)

Anonymous said...

Kudos its working !
Thanks Man !