Thursday, October 15, 2009

E-mail Attachment | Ubuntu Command Line | Howto

Tech Blog - Here is a very usefull command on sending files as attachement on Linux/Unix command line, this is specifically very usefull when using it in script to send daily report, or just for mailing client certificate directly from the server, there are two ways I know that you can use to send a file as attchemnt using command line, one is using uuencode utility with the "mail" command and the other one using "mutt", I find using mutt command to be much more reliable compared to using uuencodeutility with mail command.

uuencode utility writes an encoded version of the named input file, or standard input if no file is specified, to standard output. The output is encoded using the algorithm described in the STDOUT section and includes the file access permission bits of the input file and the decode_pathname, for re-creation of the file on another system that conforms to this specification.

If you don't have uuencode command on your system, and your running Cent OS or Redhat distribution you can find the uuencode and uudecode on the “sharutils" package.

To send a file attachment using "mail" command
$ uuencode filename.jpg filename.jpg | mail -s 'subject'

To send a file attachemnt using "mutt" command
$ echo | mutt -a filename.jpg -s 'subject'

Mutt is a small but very powerful text based program forreading electronic mail under unix operating systems,including support color terminals, MIME, and a threadedsorting mode.

Thats it!

Check out other pages:

No comments:

For suggestion and concerns E-mail