Decode email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Decode email
# 1  
Old 03-16-2005
Decode email

In pine email, when you receive an email with an attachment, the content of the attachment is incoded (content-transfer-encoding: base64). I am trying to write a shell script that will read the mail file, and it will save the attachment of an email to a directory.

I want to do this by reading mail file, save the content of the attachment into a variable, and saving that content in a directory with the same file name that it had, which is also specified in the mail file. I'm trying to figure out how I can decode the attachment in my shell script so that I can save the unencoded content of the file, rather than the hex code that is shown in the mail spool file.

Any ideas? Thanks for the help.
# 2  
Old 03-17-2005
pulled out incorrect information

Last edited by dangral; 03-21-2005 at 05:53 PM.. Reason: pulled out incorrect information
# 3  
Old 03-17-2005
Quote:
Originally Posted by dangral
uudecode should point you in the right direction.
uudecode isn't going to decode MIME base64 encoded attachments.

Do a google search for base64. There are a bazillion utilities that will decode MIME attachments.

Thomas

Last edited by tmarikle; 03-17-2005 at 01:50 PM..
# 4  
Old 03-17-2005
It's not that simple. uuencode is different than base64. This would be very rough from a shell script because shell scripts can't write binary data very easily. I wrote a binary file to base64 encoder in ksh once but it ran too slow. This will really need a external c program to handle the base 64 stuff.
# 5  
Old 03-17-2005
Quote:
Originally Posted by Perderabo
It's not that simple. uuencode is different than base64. This would be very rough from a shell script because shell scripts can't write binary data very easily. I wrote a binary file to base64 encoder in ksh once but it ran too slow. This will really need a external c program to handle the base 64 stuff.
Agreed. A c program is really the only way to do the decoding. There are base64 encoder and decoders available freely and, at least the one that I used many years ago, can find where the encoding begins and begin the decoding process regardless of any message text preceeding the attachment.

Thomas
# 6  
Old 03-17-2005
Thanks for the info. I will continue to look for a base64 decoder. I found one, but when I try to run the windows version of it, I just get a blank command prompt. When I try to configure the unix version in my unix account at school, I get a message saying permission denied, so I will need to find out how I can get the permissions to run the file that configures the decoding system. Smilie

Thanks for the pointers.
# 7  
Old 03-18-2005
I found a perfect solution, just in case anyone needs it in the future. It is a free program called UUDeview. There is both a windows version and a Unix version available for download at http://www.fpx.de/fp/Software/UUDeview/ (I hope I'm allowed to post a link on here, if not....forgive me). It gives you exact instructions on how to install it into Unix. To decode attachments of an email, you simply type the command and the file to be decoded (i.e. the mail spool file). The program will extract and decode all of the attachments, and save them to your directory with the same name as they were sent, Works like a charm!

Not only does it encode files encoded in base64, but it also decodes files encoded in BinHex, uuencoding, and xxencoding. The only setback is that when you send an attachment from yahoo, hotmail, etc, if the attachment is a regular text file or .cpp file, .java, etc, the files are not encoded, so the program does not extract these files because they are not encoded, but I will get around this by simply writing a script to extract the text files myself, and let the program do the rest.

Just figured I would put this info here just in case someone needs it in the future, which is probably very unlikely! Smilie
This User Gave Thanks to mskarica For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Decode a file

hi i have this file : <?xml version="1.0" encoding="UTF-8"?> <OnDemand xmlns="http://xsd.telecomitalia.it/Schema/crmws.entity.OnDemand" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xsd.telecomitalia.it/Schema/crmws.entity.OnDemand... (2 Replies)
Discussion started by: Francesco_IT
2 Replies

2. UNIX for Dummies Questions & Answers

What does this command do? and how to decode all other lines

Hello, I have an encoded file and I wish to see what is written inside. The first line is given below: eval "$(dd if=$0 bs=1 skip=69 2>/dev/null|gpg -d 2>/dev/null)"; exit PS: When I google above code, it says that command is use for encryption... Following lines include many strange... (2 Replies)
Discussion started by: baris35
2 Replies

3. Shell Programming and Scripting

How to decode text files?

HI experts....I am trying to decode some text files... I need little help from you people...file is of mixed type...from generated from windows based system my text files looks like this... 2.AUBZ 158 1 11 116204310 6 N 7542 E 18 02846 52833 102821 152815 ... (9 Replies)
Discussion started by: Akshay Hegde
9 Replies

4. AIX

How to decompile or decode an executable?

I have a file type of: executable (RISC System/6000 V3.1) or obj module not stripped How can I decode it? I know that this may be somewhat involved, but if you could steer me in the right direction, I would appreciate it. Thanks! (2 Replies)
Discussion started by: gg48gg
2 Replies

5. Linux

Decode the statement!!

What will the below statement do ?:confused: && { && {eval `/bin/setup 1`} || && { VAR="/tmp" } export $VAR; } (3 Replies)
Discussion started by: krishnaux
3 Replies

6. Shell Programming and Scripting

Decode %s Special Character in Sed

Greetings, I am doing something that I don't know if it is possible... I have a file with a line looks like this: <%s \n%s / %s \n%s \n> and I am trying to replace this line with <%s \n%s \n%s / %s \n%s \n> in Shell script with sed command... StringToReplace='%s \n%s / %s \n%s \n'... (2 Replies)
Discussion started by: wasabihowdi
2 Replies

7. Programming

How to Decode an image using openGL

Hi, How to decode an image using openGL library libjpeg .. which are the steps needed to do this using C language.. actually my work is to decode the image, store it on the buffer, and place it on cube surface.. please guide me,,any answer will appreciated .. (8 Replies)
Discussion started by: Ravikishore
8 Replies

8. Programming

Help to decode in perl script

Hi, I am having a file in below stucture: header { subheader1 { field1 : value field2 : value field3: value } //end of subheader1 subheader2 { subheader3 { field4 : value field5 : value field6: value } subheader4 (6 Replies)
Discussion started by: kallol
6 Replies

9. Shell Programming and Scripting

auto decode a value to different value

Okay, This is not something I've tried to do before, but what I want (need) to do is when a value is read in it gets changed to the value needed. I've been given a list of ids that I need to check against the ids I have in my system, but as is the case we don't have the same naming convention... (2 Replies)
Discussion started by: nhatch
2 Replies

10. Shell Programming and Scripting

Please decode in English

Hello: Can anyone please decode this script in English. I have also made some comments which I know.. The actual script does not have one comment also.. #! /bin/ksh . odbmsprd_env.ksh #setting the env.. echo $0 Started at : `date '+%d-%m-%Y %H:%M:%S'` # what's echo $0 ... (4 Replies)
Discussion started by: ST2000
4 Replies
Login or Register to Ask a Question