I am trying to read a set of emails. Below is my code.
- Code: Select all
<?php
$imap = imap_open("{mail.emailserver.com:143/notls}INBOX", "testing@emailserver.com", "password");
$message_count = imap_num_msg($imap);
for ($i = 1; $i <= $message_count; ++$i) {
$header = imap_header($imap, $i);
$body = imap_body($imap, $i);
$prettydate = date("jS F Y", $header->udate);
if (isset($header->from[0]->personal)) {
$personal = $header->from[0]->personal;
} else {
$personal = $header->from[0]->mailbox;
}
$email = "$personal <{$header->from[0]->mailbox}@{$header->from[0]->host}>";
//echo "On $prettydate, $email said \"$body\".\n";
echo $body;
}
imap_close($imap);
?>
I assume that the code is working coz when I send a normal email from outlook or what ever it displays them properly.
However, for a certain set of emails it DOES display some characters but no where near anything in the message.
The email reads fine in Horde/Squirrel etc. The actual email looks like
Ticker Coupon Maturity B/O Price B/O Yield Mid ASW Mid Z Axe
------------------------------------------------------------------------------
FMGAU 7 01-Nov-15 103.500/104.500 6.078 /5.822 436.8 447
FMGAU 6.375 01-Feb-16 101.250/102.250 6.058 /5.811 418.9 435
FMGAU 6.875 01-Feb-18 103.250/104.250 6.266 /6.084 378.5 395 s2.165mm
BUT MY PHP CODE SHOWS IT LIKE
VGlja2VyIENvdXBvbiBNYXR1cml0eSAgICAgQi9PICAgUHJpY2UgICAgICBCL08gIFlpZWxkICBN aWQgQVNXIE1pZCBaIEF4ZSAgICAgDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCkZNR0FVICA3ICAg ICAgMDEtTm92LTE1ICAxMDMuNTAwLzEwNC41MDAgIDYuMDc4IC81LjgyMiAgNDM2LjggICA0NDcg ICAgICAgICAgIA0KRk1HQVUgIDYuMzc1ICAwMS1GZWItMTYgIDEwMS4yNTAvMTAyLjI1MCAgNi4w NTggLzUuODExICA0MTguOSAgIDQzNSAgICAgICAgICAgDQpGTUdBVSAgNi44NzUgIDAxLUZlYi0x OCAgMTAzLjI1MC8xMDQuMjUwICA2LjI2NiAvNi4wODQgIDM3OC41ICAgMzk1ICBzMi4xNjVtbSAN Cg==
I am totally confused with this scenario.
Can any one please help me out.
Cheers
Ela Buwa


