Results 1 to 3 of 3
HellO.. How to send pictures with the mail command ?...if i want to send an html page with pictures included it always received in binary format......
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-26-2004 #1
- Join Date
- Jun 2004
sending picture with mail/sendmail
How to send pictures with the mail command ?...if i want to send an html page with pictures included it always received in binary format...
- 12-29-2004 #2
\"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
- Join Date
- Nov 2004
- Montreal, Canada
\"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps
- 12-22-2006 #3
- Join Date
- Dec 2006
Sending binary files does not work well for the Internet. We could send a binary file "surfing.jpeg" using this command:
mail -s "picture of me surfing" email@example.com < surfing.jpeg
but chances are high that the image will be unusable the time it arrives at the recipient.
During mail delivery the mail is relayed from one mail delivery agent to the next, until it finally arrives at the recipient. Each delivery agent may transform the mail message, e.g. by stripping the 8th bit of each character, removing NUL bytes (ASCII code 0), converting the end-of-line character LF ("line-feed", ASCII code 12) to a local representation (e.g. CR LF), or removing trailing space or TAB characters from each line.
Since only some characters are sure to arrive unmodified, the traditional solution is to encode the mail from binary format to a text format that is safe to transmit. The program used for this is called "uuencode" ("UNIX to UNIX encoding"), the program to decode the data is called "uudecode".
The simplest way to send a file as a mail attachment is shown by the following example:
$ uuencode surfing.jpeg surfing.jpeg | mail firstname.lastname@example.org
That's all! If Sylvia uses a current mail reader like Mozilla, Netscape Messenger or Microsoft Exchange, she will see a mail containing just one file attachment: the file "surfing.jpeg". In the command above we had to specify the file name two times: the first name denotes the input file to be encoded, and the second name is the file name the recipient will see.
This way we can include normal text, too:
$ (cat mailtext; uuencode surfing.jpeg surfing.jpeg) |
Note: The file name "surfing.jpeg" again appears twice on the uuencode command line: the first time to specify the input file name, the second time for the remote extraction file name.
The first "cat" will prepend the contents of the file "mailtext" to the "uuencode"ed data of the image "surfing.jpeg". Both commands are executed within a sub shell, to combine the output of both commands to one output stream redirected to the "mail" command.
This method of sending file attachments works fairly well, but still has some shortcomings:
* Many user agents cannot directly decode this kind of file attachments, e.g. "Eudora". Some mail agents explicitly require the decoding of the mail using the program "uudecode"
* The "uuencode" encoding is not standardized. Text encoded on one system may not be decoded correctly by the recipient's system
[the content of the mail message was saved to
the file "mail.uue"]
$ uudecode mail.uue
The file "surfing.jpeg" was written to the current directory
The next method does not have this disadvantages. It works with most (newer) mail user agents and uses the "Multipurpose Internet Mail Extensions" (MIME).