Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14047 > unrolled thread
| Started by | stef_204 <notvalid@nomail.nul> |
|---|---|
| First post | 2014-07-02 15:53 +0000 |
| Last post | 2014-07-10 13:18 +0000 |
| Articles | 20 on this page of 34 — 10 participants |
Back to article view | Back to comp.lang.php
Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-02 15:53 +0000
Re: Encoding Problems Jerry Stuckle <jstucklex@attglobal.net> - 2014-07-02 15:15 -0400
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-03 10:18 +0000
Re: Encoding Problems Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-02 21:49 +0200
Re: Encoding Problems bill <william@TechServSys.com> - 2014-07-03 08:09 -0400
Re: Encoding Problems Christoph Michael Becker <cmbecker69@arcor.de> - 2014-07-02 22:25 +0200
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-03 10:16 +0000
Re: Encoding Problems bill <william@TechServSys.com> - 2014-07-03 08:08 -0400
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-03 13:17 +0000
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-05 03:16 +0200
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-05 03:19 +0200
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-10 13:57 +0000
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-11 18:47 +0200
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-14 08:35 +0000
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-18 09:06 +0000
Re: Encoding Problems Tim Streater <timstreater@greenbee.net> - 2014-07-18 10:29 +0100
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-18 09:38 +0000
Re: Encoding Problems Tim Streater <timstreater@greenbee.net> - 2014-07-18 11:05 +0100
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-18 11:42 +0000
Re: Encoding Problems Tim Streater <timstreater@greenbee.net> - 2014-07-18 14:32 +0100
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-19 09:36 +0200
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-29 13:58 +0000
Re: Encoding Problems Christoph Michael Becker <cmbecker69@arcor.de> - 2014-07-05 03:28 +0200
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-06 01:36 +0200
Re: Encoding Problems Denis McMahon <denismfmcmahon@gmail.com> - 2014-07-06 02:16 +0000
Re: Encoding Problems Richard Damon <Richard@Damon-Family.org> - 2014-07-05 23:19 -0400
Re: Encoding Problems gordonb.defz8@burditt.org (Gordon Burditt) - 2014-07-06 00:21 -0500
Re: Encoding Problems Richard Damon <Richard@Damon-Family.org> - 2014-07-06 07:14 -0400
Re: Encoding Problems Denis McMahon <denismfmcmahon@gmail.com> - 2014-07-07 01:24 +0000
Re: Encoding Problems Christoph Michael Becker <cmbecker69@arcor.de> - 2014-07-06 15:30 +0200
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-06 21:46 +0200
Re: Encoding Problems Richard Damon <Richard@Damon-Family.org> - 2014-07-06 16:21 -0400
Re: Encoding Problems Arno Welzel <usenet@arnowelzel.de> - 2014-07-07 03:49 +0200
Re: Encoding Problems stef_204 <notvalid@nomail.nul> - 2014-07-10 13:18 +0000
Page 1 of 2 [1] 2 Next page →
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-02 15:53 +0000 |
| Subject | Encoding Problems |
| Message-ID | <lp19to$r2$1@dont-email.me> |
Hi,
Newbie at php; please bear with me.
I am trying to use a script which basically creates an xml feed for email
messages found in an IMAP account; one can then either subscribe to feed
via an rss reader/aggregator or use browser to read html page.
Here is the script: <http://linuxtrove.com/wp/?p=209>
(imap2rss.php)
My problem: almost all of the messages (emails) show garbled text, I
believe due to encoding problems.
Here is a picture of how it looks both using a browser like Firefox or an
rss news feed reader.
<http://imagebin.org/314843>
The emails are legible using an email client but not via the xml and html
page created by php script.
This is what I first thought:
It looks like the emails are plain text but using utf-8 and when the feed
is created (and the html page); there is no recognition of the encoding
and it all gets garbled, etc.
Server (shared) is running PHP 5.2.17 on Apache/2.2.22.
PHP config --> default_charset: iso-8859-1
I cannot change the config on the server since it is shared hosting but I
can certainly modify the script to hopefully fix this issue.
I have tried to insert in the script:
ini_set( 'default_charset', 'UTF-8' );
htmlentities( $string, ENT_COMPAT, "UTF-8" );
header('Content-type: text/plain; charset=utf-8');
but no joy.
I have also tried to add to .htaccess IndexOptions +Charset=UTF-8 No joy
there either.
I could be completely wrong about the utf-8 issue; and perhaps it has
more something to do with decoding base64 in general.
This is what I now think is the problem, more specifically:
I have just tried a base64 online decoder and pasted the garbled text in
it and used the "decode" online feature, and the result is perfectly
legible once decoded, whether I choose utf-8 or ascii as charset (but I
should use utf-8).
So, looks like the feed is "echoed" or "printed" in base64 format....
It doesn't look like charset is the problem but decoding base64.
I can see the base64_decode function here
<http://www.php.net/manual/en/function.base64-decode.php>
but not sure if this is the right way to go about this; or how to apply
it in this script.
I am going about this fairly blind, I must say, and doing trial and error
which is just wrong....
Again, this is the script.
<http://linuxtrove.com/wp/?p=209>
Any pointers?
Tx.
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2014-07-02 15:15 -0400 |
| Message-ID | <lp1loc$gs1$1@dont-email.me> |
| In reply to | #14047 |
On 7/2/2014 11:53 AM, stef_204 wrote:
> Hi,
>
> Newbie at php; please bear with me.
>
> I am trying to use a script which basically creates an xml feed for email
> messages found in an IMAP account; one can then either subscribe to feed
> via an rss reader/aggregator or use browser to read html page.
>
> Here is the script: <http://linuxtrove.com/wp/?p=209>
> (imap2rss.php)
>
> My problem: almost all of the messages (emails) show garbled text, I
> believe due to encoding problems.
>
> Here is a picture of how it looks both using a browser like Firefox or an
> rss news feed reader.
>
> <http://imagebin.org/314843>
>
> The emails are legible using an email client but not via the xml and html
> page created by php script.
>
> This is what I first thought:
> It looks like the emails are plain text but using utf-8 and when the feed
> is created (and the html page); there is no recognition of the encoding
> and it all gets garbled, etc.
>
> Server (shared) is running PHP 5.2.17 on Apache/2.2.22.
> PHP config --> default_charset: iso-8859-1
>
> I cannot change the config on the server since it is shared hosting but I
> can certainly modify the script to hopefully fix this issue.
>
> I have tried to insert in the script:
> ini_set( 'default_charset', 'UTF-8' );
> htmlentities( $string, ENT_COMPAT, "UTF-8" );
> header('Content-type: text/plain; charset=utf-8');
> but no joy.
>
> I have also tried to add to .htaccess IndexOptions +Charset=UTF-8 No joy
> there either.
>
> I could be completely wrong about the utf-8 issue; and perhaps it has
> more something to do with decoding base64 in general.
>
> This is what I now think is the problem, more specifically:
> I have just tried a base64 online decoder and pasted the garbled text in
> it and used the "decode" online feature, and the result is perfectly
> legible once decoded, whether I choose utf-8 or ascii as charset (but I
> should use utf-8).
>
> So, looks like the feed is "echoed" or "printed" in base64 format....
> It doesn't look like charset is the problem but decoding base64.
>
> I can see the base64_decode function here
> <http://www.php.net/manual/en/function.base64-decode.php>
> but not sure if this is the right way to go about this; or how to apply
> it in this script.
>
> I am going about this fairly blind, I must say, and doing trial and error
> which is just wrong....
>
> Again, this is the script.
> <http://linuxtrove.com/wp/?p=209>
>
> Any pointers?
>
> Tx.
>
Stef,
Just looking at the output, my immediate thought was "this is base64
encoded". That would match if it works in an email reader as a base64
encoded attachment.
I don't have the time to go through 300+ LOC to try to figure out what
you code is doing, but when sending as either XML or HTML, you need to
first base64_decode() the text. Once you've done that, apply
htmlentities() to the string to encode the HTML entities. Then send it
to the RSS or HTML feed.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-03 10:18 +0000 |
| Message-ID | <lp3alr$n10$2@dont-email.me> |
| In reply to | #14048 |
On Wed, 02 Jul 2014 15:15:23 -0400, Jerry Stuckle wrote: > Stef, > > Just looking at the output, my immediate thought was "this is base64 > encoded". That would match if it works in an email reader as a base64 > encoded attachment. > > I don't have the time to go through 300+ LOC to try to figure out what > you code is doing, but when sending as either XML or HTML, you need to > first base64_decode() the text. Once you've done that, apply > htmlentities() to the string to encode the HTML entities. Then send it > to the RSS or HTML feed. Yes, I think you've pretty much nailed it; will work on that today and see if I can resolve it. Thanks for feedback.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-07-02 21:49 +0200 |
| Message-ID | <2448728.jUImtIHjQu@PointedEars.de> |
| In reply to | #14047 |
stef_204 wrote: > Newbie at php; please bear with me. OK, I will not killfile you right away. Please read and adhere to: - <http://www.eternal-september.org/index.php?language=en&showpage=terms> - <http://www.interhack.net/pubs/munging-harmful/> And get a real name. PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>
[toc] | [prev] | [next] | [standalone]
| From | bill <william@TechServSys.com> |
|---|---|
| Date | 2014-07-03 08:09 -0400 |
| Message-ID | <lp3h5c$jd$2@speranza.aioe.org> |
| In reply to | #14049 |
On 7/2/2014 3:49 PM, Thomas 'PointedEars' Lahn wrote: > stef_204 wrote: > >> Newbie at php; please bear with me. > > OK, I will not killfile you right away. > > Please read and adhere to: > > - <http://www.eternal-september.org/index.php?language=en&showpage=terms> > - <http://www.interhack.net/pubs/munging-harmful/> > > And get a real name. > > > PointedEars > Wait a minute. A guy named "PointedEars" is complaining about a real name. I want to see a copy of the birth certificate with PointedEars on it. LOL I know you are talking about the from: address, but I couldn't resist. --bill
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-07-02 22:25 +0200 |
| Message-ID | <53b46ab4$0$6612$9b4e6d93@newsspool4.arcor-online.net> |
| In reply to | #14047 |
stef_204 wrote: > Here is the script: <http://linuxtrove.com/wp/?p=209> > (imap2rss.php) > > My problem: almost all of the messages (emails) show garbled text, I > believe due to encoding problems. Indeed, that seems to be a encoding problem. Not so much a character encoding problem but rather a body transfer encoding problem. You will most likely have to take into account the "encoding" property of imap_fetchstructure()'s return value. Please heed Thomas' advice. It's always nice to "know" who you're talking to and to be able to send a private reply, if appropriate. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-03 10:16 +0000 |
| Message-ID | <lp3aii$n10$1@dont-email.me> |
| In reply to | #14050 |
On Wed, 02 Jul 2014 22:25:31 +0200, Christoph Michael Becker wrote: > Indeed, that seems to be a encoding problem. Not so much a character > encoding problem but rather a body transfer encoding problem. You will > most likely have to take into account the "encoding" property of > imap_fetchstructure()'s return value. Will look into it further. Thanks. > > Please heed Thomas' advice. It's always nice to "know" who you're > talking to and to be able to send a private reply, if appropriate. Have added email address so I can be contacted privately as needed; been a while since I've used newsgroups.
[toc] | [prev] | [next] | [standalone]
| From | bill <william@TechServSys.com> |
|---|---|
| Date | 2014-07-03 08:08 -0400 |
| Message-ID | <lp3h3b$jd$1@speranza.aioe.org> |
| In reply to | #14047 |
On 7/2/2014 11:53 AM, stef_204 wrote: Are you the stef that translates HTML-kit into Dutch? If you are, nice seeing you here. --bill
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-03 13:17 +0000 |
| Message-ID | <lp3l4e$vkk$1@dont-email.me> |
| In reply to | #14053 |
On Thu, 03 Jul 2014 08:08:09 -0400, bill wrote: > On 7/2/2014 11:53 AM, stef_204 wrote: > > > Are you the stef that translates HTML-kit into Dutch? > If you are, nice seeing you here. > > --bill no connection at all with the person you refer to; sorry....
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2014-07-05 03:16 +0200 |
| Message-ID | <53B7520B.8080506@arnowelzel.de> |
| In reply to | #14047 |
stef_204, 2014-07-02 17:53:
> Hi,
>
> Newbie at php; please bear with me.
>
> I am trying to use a script which basically creates an xml feed for email
> messages found in an IMAP account; one can then either subscribe to feed
> via an rss reader/aggregator or use browser to read html page.
>
> Here is the script: <http://linuxtrove.com/wp/?p=209>
> (imap2rss.php)
>
> My problem: almost all of the messages (emails) show garbled text, I
> believe due to encoding problems.
>
> Here is a picture of how it looks both using a browser like Firefox or an
> rss news feed reader.
>
> <http://imagebin.org/314843>
This is base64 and as to be decoded.
[...]
> I could be completely wrong about the utf-8 issue; and perhaps it has
> more something to do with decoding base64 in general.
Yep - that's the point.
> This is what I now think is the problem, more specifically:
> I have just tried a base64 online decoder and pasted the garbled text in
> it and used the "decode" online feature, and the result is perfectly
> legible once decoded, whether I choose utf-8 or ascii as charset (but I
> should use utf-8).
>
> So, looks like the feed is "echoed" or "printed" in base64 format....
> It doesn't look like charset is the problem but decoding base64.
Yep.
>
> I can see the base64_decode function here
> <http://www.php.net/manual/en/function.base64-decode.php>
> but not sure if this is the right way to go about this; or how to apply
> it in this script.
Well - unfortunately there is no easy "put it in there and it works".
First of all: Just testing for the subtype "PLAIN" (is not enough. You
also have to check for the encoding.
As far i see, this should be added here:
if($msgStructure->subtype=="PLAIN")
$body = renderPlainText($body);
So extend that for the encoding:
if($msgStructure->subtype=="PLAIN")
{
switch($msgStructure->encoding)
{
case 4:
// Body text is quoted-printable encoded
$body = quoted_printable_decode($body);
break;
case 3:
// Body text is base64 encoded
$body = base64_decode($data);
break;
}
$body = renderPlainText($body);
}
Also see <http://php.net/manual/en/function.imap-fetchstructure.php> and
the comments there.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2014-07-05 03:19 +0200 |
| Message-ID | <53B7529D.9050002@arnowelzel.de> |
| In reply to | #14063 |
Arno Welzel, 2014-07-05 03:16:
> stef_204, 2014-07-02 17:53:
>
>> Hi,
>>
>> Newbie at php; please bear with me.
>>
>> I am trying to use a script which basically creates an xml feed for email
>> messages found in an IMAP account; one can then either subscribe to feed
>> via an rss reader/aggregator or use browser to read html page.
>>
>> Here is the script: <http://linuxtrove.com/wp/?p=209>
>> (imap2rss.php)
>>
>> My problem: almost all of the messages (emails) show garbled text, I
>> believe due to encoding problems.
>>
>> Here is a picture of how it looks both using a browser like Firefox or an
>> rss news feed reader.
>>
>> <http://imagebin.org/314843>
>
> This is base64 and as to be decoded.
>
> [...]
>> I could be completely wrong about the utf-8 issue; and perhaps it has
>> more something to do with decoding base64 in general.
>
> Yep - that's the point.
>
>> This is what I now think is the problem, more specifically:
>> I have just tried a base64 online decoder and pasted the garbled text in
>> it and used the "decode" online feature, and the result is perfectly
>> legible once decoded, whether I choose utf-8 or ascii as charset (but I
>> should use utf-8).
>>
>> So, looks like the feed is "echoed" or "printed" in base64 format....
>> It doesn't look like charset is the problem but decoding base64.
>
> Yep.
>
>>
>> I can see the base64_decode function here
>> <http://www.php.net/manual/en/function.base64-decode.php>
>> but not sure if this is the right way to go about this; or how to apply
>> it in this script.
>
> Well - unfortunately there is no easy "put it in there and it works".
>
> First of all: Just testing for the subtype "PLAIN" (is not enough. You
> also have to check for the encoding.
>
> As far i see, this should be added here:
>
> if($msgStructure->subtype=="PLAIN")
> $body = renderPlainText($body);
>
> So extend that for the encoding:
>
> if($msgStructure->subtype=="PLAIN")
> {
> switch($msgStructure->encoding)
> {
> case 4:
> // Body text is quoted-printable encoded
> $body = quoted_printable_decode($body);
> break;
>
> case 3:
> // Body text is base64 encoded
> $body = base64_decode($data);
Ups - sorry for the c&p typo. Of course it should be:
$body = base64_decode($body);
> break;
> }
>
> $body = renderPlainText($body);
> }
>
> Also see <http://php.net/manual/en/function.imap-fetchstructure.php> and
> the comments there.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-10 13:57 +0000 |
| Message-ID | <lpm64b$28i$2@dont-email.me> |
| In reply to | #14064 |
On Sat, 05 Jul 2014 03:19:25 +0200, Arno Welzel wrote:
>> So extend that for the encoding:
>>
>> if($msgStructure->subtype=="PLAIN")
>> {
>> switch($msgStructure->encoding)
>> {
>> case 4:
>> // Body text is quoted-printable encoded $body =
>> quoted_printable_decode($body); break;
>>
>> case 3:
>> // Body text is base64 encoded $body = base64_decode($data);
>
> Ups - sorry for the c&p typo. Of course it should be:
>
> $body = base64_decode($body);
>
>> break;
>> }
>>
>> $body = renderPlainText($body);
>> }
Arno,
The above seems to work. Thanks.
I still get a little bit of garbled text due to charset utf-8 (I believe)
but we are now 99% better on the $body.
I now need to apply the fix to the $subject.
Looking into it now.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2014-07-11 18:47 +0200 |
| Message-ID | <53C0153B.9070807@arnowelzel.de> |
| In reply to | #14090 |
stef_204, 2014-07-10 15:57:
> On Sat, 05 Jul 2014 03:19:25 +0200, Arno Welzel wrote:
>
>>> So extend that for the encoding:
>>>
>>> if($msgStructure->subtype=="PLAIN")
>>> {
>>> switch($msgStructure->encoding)
>>> {
>>> case 4:
>>> // Body text is quoted-printable encoded $body =
>>> quoted_printable_decode($body); break;
>>>
>>> case 3:
>>> // Body text is base64 encoded $body = base64_decode($data);
>>
>> Ups - sorry for the c&p typo. Of course it should be:
>>
>> $body = base64_decode($body);
>>
>>> break;
>>> }
>>>
>>> $body = renderPlainText($body);
>>> }
>
> Arno,
>
> The above seems to work. Thanks.
> I still get a little bit of garbled text due to charset utf-8 (I believe)
> but we are now 99% better on the $body.
Just keep in mind, that my example is not complete and just a suggestion
how to start - there should also be a case to handle text with transfer
encoding which does not need decoding at all and a default case to
handle unknown encodings.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-14 08:35 +0000 |
| Message-ID | <lq04ov$58n$1@dont-email.me> |
| In reply to | #14100 |
On Fri, 11 Jul 2014 18:47:55 +0200, Arno Welzel wrote: > Just keep in mind, that my example is not complete and just a suggestion > how to start - there should also be a case to handle text with transfer > encoding which does not need decoding at all and a default case to > handle unknown encodings. Yes, will keep improving it. Tx for feedack,
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-18 09:06 +0000 |
| Message-ID | <lqao35$8v5$1@dont-email.me> |
| In reply to | #14100 |
On Fri, 11 Jul 2014 18:47:55 +0200, Arno Welzel wrote: > Just keep in mind, that my example is not complete and just a suggestion > how to start - there should also be a case to handle text with transfer > encoding which does not need decoding at all and a default case to > handle unknown encodings. Arno, Sorry to ask but I am struggling with the "subject" part of the email. I tried to find a fix but not joy, yet. I can decode the base64 encoded subject of each email individually by adding a: mb_decode_mimeheader as follows, but that's really just a "hack" and not proper, IMHO. And that only decodes $subject on the html page produced for individual emails, not the top level html page/rss feed which lists all of the emails. The subjects there are still reading: "=?UTF-8?B?"InsertGarbledText (base64) here"=?= The section I refer to where I inserted the md_decode_mimehader starts on line 203 in original script (I believe that's the right line number but I commented the script so not sure it will match yours in terms of line number.) <html> <head> <title><?php echo mb_decode_mimeheader($subject);?></title> </head> <body> <div style="background:#eeeeee; border:solid 1px" <strong><?php echo mb_decode_mimeheader($subject); ?></strong><br /> <i><?php echo "by: ".$author.", @ ".$entryDate;?></i> </div> <br /> I need a different (more proper) fix earlier in the script; have tried many different ones but no joy yet. Any further hints or pointers? Thanks.
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2014-07-18 10:29 +0100 |
| Message-ID | <180720141029326419%timstreater@greenbee.net> |
| In reply to | #14102 |
In article <lqao35$8v5$1@dont-email.me>, stef_204 <notvalid@nomail.nul> wrote: > Sorry to ask but I am struggling with the "subject" part of the email. > > I tried to find a fix but not joy, yet. > > I can decode the base64 encoded subject of each email individually by > adding a: mb_decode_mimeheader as follows, but that's really just a > "hack" and not proper, IMHO. > > And that only decodes $subject on the html page produced for individual > emails, not the top level html page/rss feed which lists all of the > emails. > > The subjects there are still reading: > "=?UTF-8?B?"InsertGarbledText (base64) here"=?= These are called "encoded words". You can read about it in RFC2047, or look up the WikiPedia article on MIME (in caps). You'll have to write some PHP to decode those. In general the format is: introducer: =? charset: UTF-8 (in this case) separator: ? coding: B for base64, Q for quoted printable separator: ? encoded text follows terminator: ?= That will allow you to pick the item apart and know what to do with it. BTW, if you are doing stuff with emails, there's no substitute for reading the RFCs and understanding how emails are put together. That's what I did as part of the process for writing my own email client. RFCs 2045, 2046, 2047, 2048, and 2049 are a good place to start. -- "People don't buy Microsoft for quality, they buy it for compatibility with what Bob in accounting bought last year. Trace it back - they buy Microsoft because the IBM Selectric didn't suck much" - P Seebach, afc
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-18 09:38 +0000 |
| Message-ID | <lqapur$mnb$1@dont-email.me> |
| In reply to | #14103 |
On Fri, 18 Jul 2014 10:29:32 +0100, Tim Streater wrote: > BTW, if you are doing stuff with emails, there's no substitute for > reading the RFCs and understanding how emails are put together. That's > what I did as part of the process for writing my own email client. RFCs > 2045, 2046, 2047, 2048, and 2049 are a good place to start. Hi Tim, I agree with you--I'm just really pressed at the moment on this work project unfortunately and need to get it up and running ASAP. Not ideal at all, obviously, but coding/programming is only incidental to my work and not my main work. Thanks for your feedback.
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2014-07-18 11:05 +0100 |
| Message-ID | <180720141105476872%timstreater@greenbee.net> |
| In reply to | #14104 |
In article <lqapur$mnb$1@dont-email.me>, stef_204 <notvalid@nomail.nul> wrote: > On Fri, 18 Jul 2014 10:29:32 +0100, Tim Streater wrote: > > > BTW, if you are doing stuff with emails, there's no substitute for > > reading the RFCs and understanding how emails are put together. That's > > what I did as part of the process for writing my own email client. RFCs > > 2045, 2046, 2047, 2048, and 2049 are a good place to start. > > I agree with you--I'm just really pressed at the moment on this work > project unfortunately and need to get it up and running ASAP. > Not ideal at all, obviously, but coding/programming is only incidental to > my work and not my main work. Um, I see the problem. Would it help if I emailed you the function I put together for the purpose? -- "People don't buy Microsoft for quality, they buy it for compatibility with what Bob in accounting bought last year. Trace it back - they buy Microsoft because the IBM Selectric didn't suck much" - P Seebach, afc
[toc] | [prev] | [next] | [standalone]
| From | stef_204 <notvalid@nomail.nul> |
|---|---|
| Date | 2014-07-18 11:42 +0000 |
| Message-ID | <lqb17k$9bb$1@dont-email.me> |
| In reply to | #14105 |
On Fri, 18 Jul 2014 11:05:47 +0100, Tim Streater wrote: > Um, I see the problem. Would it help if I emailed you the function I put > together for the purpose? Sure, let's give it a shot and see if I am able to integrate it in to the script to resolve the issue.
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2014-07-18 14:32 +0100 |
| Message-ID | <180720141432562643%timstreater@greenbee.net> |
| In reply to | #14106 |
In article <lqb17k$9bb$1@dont-email.me>, stef_204 <notvalid@nomail.nul> wrote: > On Fri, 18 Jul 2014 11:05:47 +0100, Tim Streater wrote: > > > Um, I see the problem. Would it help if I emailed you the function I put > > together for the purpose? > > Sure, let's give it a shot and see if I am able to integrate it in to the > script to resolve the issue. OK - on its way, let me know if you don't receive it. -- "People don't buy Microsoft for quality, they buy it for compatibility with what Bob in accounting bought last year. Trace it back - they buy Microsoft because the IBM Selectric didn't suck much" - P Seebach, afc
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.php
csiph-web