Monday, December 12, 2005

How to Unix:To Send An Attachment From Unix

I posted once how to send mail from unix.Anyway that can not be called a post as it merely described things.It was just an information.Today i felt a need to send an attachment.But its not as easy as sending mail as text only.
Becuase if we try to send a small midi or wav file by doing a simple mailx like follow,it may not work.
$ mailx -s "Warning!! May not reach as it is!!" rakib004@yahoo.com < BritneySpears.mid

Because while delivery from one mail agent to other,they will strip off or add bytes as per their standards.SO how to do this then?

For that u need to encode before sending.And then send it.
$ uuencode BritneySpears.mid codedBritneySpears.mid| mailx -s "ATTACHMENT" rakib004@yahoo.com
And if you want to tell him wats the attachment is in text,then:
$ (cat MailBody.txt; uuencode BritneySpears.mid codedBritneySpears.mid)| mailx -s "ATTACHMENT_WITH_BODY" rakib004@yahoo.com

What uuencode do:
(From Unix MAN Page)
uuencode takes the named source file (default standard input) and
produces an encoded version on the standard output. The encoding uses
only printing ASCII characters, includes the original mode of the
input file, and preserves the value of the remotedest argument which
is the intended name for the file when it is restored later on the
remote system.

FROM ORAFAQ:
(Good Script )

http://www.orafaq.com/scripts/unix/sendmail.txt
http://www.orafaq.com/scripts/unix/mailx.txt
LINK TO MY OTHER POST:
http://mahasim.blogspot.com/2005/05/how-to-send-mail-from-unix.html

Sometimes your mail may not be able to decode the file sent to you using uuencode and mailx.

In that case you may follow the following command:-
$ sendmail m.a.hasim@gmail.com<> `cat hasim.txt`
> `uuencode hasim.txt hasim.txt`
> END

Labels:

0 Comments:

Post a Comment

<< Home