Reading Emails with PHP

the mail() function

Moderators: macek, egami, gesf

elabuwa
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jun 06, 2011 8:18 pm

Reading Emails with PHP

Postby elabuwa » Mon Jun 06, 2011 8:22 pm

Hi guys,

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. :help: :help:
Can any one please help me out. :help: :help: :help: :( :(

Cheers
Ela Buwa

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: Reading Emails with PHP

Postby Nullsig » Tue Jun 07, 2011 6:54 am

Those e-mails are encrypted using TLS or SSL. You would have to find a way to decrypt them, they will require you to have to public key to decrypt them.

I don't know exactly how to obtain that or the procedure on how to decrypt the text but, I can definitively say that is what the problem you are experiencing is.


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 2 guests