odstranjevanje headerjev iz email sporočila

--047d7b343cf6a739b804fdc72eef Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable testiranje spletnih aplikacij je lahko tudi zelo u=C4=8Dinkovito :) --=20 Lep pozdrav, Oseba XY --047d7b343cf6a739b804fdc72eef Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
vsebina email sporocila se zacne s to vrstico <-- ZACETEK SPOROCILA
fusbalsvetovnoprvenstvojekul
vsebina email sporocila se konca s to vrstico <-- KONEC SPOROCILA

--047d7b343cf6a739b804fdc72eef--

zgoraj sem prilepil primer kode, ko iz serverja preberem email sporocilo. rad bi izlocil tisto kar je generirano nepotrebno - headerje in tisti del v footerju. any idea, obstaja kaka funkcija?

4 odgovori

Kaj res ne ve nihče, kako se headerji iz mejlov odstranijo? .... sem poizkušal na več načinov, pa ni neke idealne rešitve. Any Idea?

Kako pa prebereš mail?
Imaš samo txt ali preko imapa/pop?*

ovcax s tem spodaj preberem mejle s serverja.

<?php
class Emailreader {
public $conn;
private $inbox;
private $msg
cnt;
private $server = 'mail.domena.com';
private $user = 'email@domena.com';
private $pass = '123456';
private $port = 587; // adjust according to server settings

function __construct() {
    $this->connect();
    $this->inbox();
}
function close() {
    $this->inbox = array();
    $this->msg_cnt = 0;
    imap_errors();
    imap_alerts();
    imap_close($this->conn);
}

function connect() {
    $this->conn = imap_open('{'.$this->server.'/notls}', $this->user, $this->pass);
}

function move($msg_index, $folder='INBOX.Processed') {

    imap_mail_move($this->conn, $msg_index, $folder);
    imap_expunge($this->conn);
    $this->inbox();
}

function get($msg_index=NULL) {
    if (count($this->inbox) <= 0) {
        return array();
    }
    elseif ( ! is_null($msg_index) && isset($this->inbox[$msg_index])) {
        return $this->inbox[$msg_index];
    }
    return $this->inbox[0];
}
function inbox() {
    $this->msg_cnt = imap_num_msg($this->conn);
    $in = array();
    for($i = 1; $i <= $this->msg_cnt; $i++) {
        $in[] = array(
            'index'     => $i,
            'header'    => imap_headerinfo($this->conn, $i),
            'body'      => imap_body($this->conn, $i),
            'structure' => imap_fetchstructure($this->conn, $i)
        );
    }
    $this->inbox = $in;
    return $in;
}

}
?>

Mogoče ti bo tole prišlo prav: Plancake email parser