The following command can be used to attach files in the mail while sending it using 'mailx' command in UNIX OS.
uuencode sourcefilename destfilename | mailx -m -s "My attachment" email@example.com
The uuencode command converts a binary file to ASCII data. This is useful before using BNU (or uucp) mail to send the file to a remote system. The uudecode command converts ASCII data created by the uuencode command back into its original binary form.
The uuencode command takes the named SourceFile (default standard input) and produces an encoded version on the standard output. The encoding uses only printable ASCII characters, and includes the mode of the file and the OutputFile filename used for recreation of the binary image on the remote system.
To encode the file unix on the local system and mail it to the user shishir on another system called mysys, enter:
uuencode unix unix | mail firstname.lastname@example.org