12-10-2008
My code was meant to show you the general process of MIME decoding (and mostly concept). It was not quite good for production use. Parsing a real-world email message is likely slightly more complex due to existence of variations.
To be frank, if you can get hold of PHP 5, as indicated in the inline comment, the simplest approach would be to use the iconv_mime_decode() function which is a one-stop shop of what you want. There was a (intentional) flaw in my posted code because it didn't handle the case where the encoding is quoted-printable, that is also supported by MIME. For simplicity, I only posted the part which decodes Base64, because that was used in your sample posted.
If you get hold of the concepts needed, you may then check other languages or tools to see if they may better suit your environment compared with PHP. As PHP install is typically pretty big, it may not be necessarily suitable in all deployment environments (say on very limited storage space).
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi, I'm using putty and when I try to write ü it writes | (or when I try to write é , it writes i)
I tried to change settings/translation of putty but with no success
I have KSH
# locale
LANG=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"... (3 Replies)
Discussion started by: palmer18
3 Replies
2. Shell Programming and Scripting
Hi,
I'm trying to strip all lines between two headers in a file:
### BEGIN ###
Text to remove, contains all kinds of characters
...
Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c
om/updates/
Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies
3. Shell Programming and Scripting
Hi ,
I have a typical situation. I have 4 files and with different headers (number of headers is varible ).
I need to make such a merged file which will have headers combined from all files (comman coluns should appear once only).
For example -
File 1
H1|H2|H3|H4
11|12|13|14
21|22|23|23... (1 Reply)
Discussion started by: marut_ashu
1 Replies
4. Shell Programming and Scripting
Hi experts,
I have a gz file from other system(solaris), which is ftped to our system(solaris).
After gunzip, the file is a xml file and we are using ORACLE built in xml transformiing tool ORAXSL to transform XML to TXT.
Now the issue is we come accross issue regarding UTF8 as below:... (1 Reply)
Discussion started by: summer_cherry
1 Replies
5. Shell Programming and Scripting
Hi,
I am beginner to Unix.
My requirement is to validate the encoding used in the incoming file(csv,txt).If it is encoded with UTF-8 format,then the file should remain as such otherwise i need to chnage the encoding to UTF-8.
Please advice me how to proceed on this. (7 Replies)
Discussion started by: cnraja
7 Replies
6. Shell Programming and Scripting
Hi ,
I have a sql query in the unix script ,whose output is shown below.I want to convert this output to HTML table format & send email from unix with this table as email body.
p_id src_system amount
1 A 100
2 B 200
3 C ... (3 Replies)
Discussion started by: jagadeeshn04
3 Replies
7. UNIX for Dummies Questions & Answers
Hi All
I am working on AIX 7.1 and I am trying to show an output that I get from "cat" a log file to email. However in email I get the below output:
In the script I have defined the colors as:
#!/bin/sh
echo "\033
Below is the script I have created to send this output:
... (9 Replies)
Discussion started by: Bubs
9 Replies
8. UNIX for Dummies Questions & Answers
I'm trying to pick up some Unix SysAdmin skills on my own outside of work through the use of the "Unix and Linux System Administrators Handbook." I've found the exercises to be very beneficial, until I came to this.... "What path did the email take? To Whom was it addressed, and to whom was it... (0 Replies)
Discussion started by: ksmarine1980
0 Replies
9. UNIX for Dummies Questions & Answers
Hi all
I need help converting a text file into a html table in bash and I need to email this table. The text file looks like the below. Two columns with multiple rows. Top row being header.
Application Name Application Status
Application 1 Open
Application 2 ... (2 Replies)
Discussion started by: hitmanjd
2 Replies
10. Solaris
Hi all!!
I´m using command file -i myfile.xml to validate XML file encoding, but it is just saying regular file . I´m expecting / looking an output as UTF8 or ANSI / ASCII
Is there command to display the files encoding?
Thank you! (2 Replies)
Discussion started by: mrreds
2 Replies
LEARN ABOUT MOJAVE
mime::quotedprint5.18
MIME::QuotedPrint(3pm) Perl Programmers Reference Guide MIME::QuotedPrint(3pm)
NAME
MIME::QuotedPrint - Encoding and decoding of quoted-printable strings
SYNOPSIS
use MIME::QuotedPrint;
$encoded = encode_qp($decoded);
$decoded = decode_qp($encoded);
DESCRIPTION
This module provides functions to encode and decode strings into and from the quoted-printable encoding specified in RFC 2045 - MIME
(Multipurpose Internet Mail Extensions). The quoted-printable encoding is intended to represent data that largely consists of bytes that
correspond to printable characters in the ASCII character set. Each non-printable character (as defined by English Americans) is
represented by a triplet consisting of the character "=" followed by two hexadecimal digits.
The following functions are provided:
encode_qp( $str)
encode_qp( $str, $eol)
encode_qp( $str, $eol, $binmode )
This function returns an encoded version of the string ($str) given as argument.
The second argument ($eol) is the line-ending sequence to use. It is optional and defaults to "
". Every occurrence of "
" is
replaced with this string, and it is also used for additional "soft line breaks" to ensure that no line end up longer than 76
characters. Pass it as "