Vom Lima-City Mail-Account E-Mail abholen
lima-city → Forum → Programmiersprachen → PHP, MySQL & .htaccess
abholen
array
boxen
code
date
detail
flag
forum
host
http
image
message
nachricht
overall
part
pop
port
postfach
text
type
-
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage
-
schuelerhc schrieb: Schau hier mal ob was für dich dabei ist:
http://www.tutorials.de/forum/php/204611-mail-klasse-zum-abholen-der-mails-ueber-pop3.html
ich habe auf der seite das gefunden:
<html> <body> <? $boMail = new boMail("mail@meinedomain.de","meinpasswort","INBOX","mail.lima-city.de"); //gibt alle nachrichten des Postfaches in ein Array: $overall=$boMail->getOverview(); echo $boMail->mailsnum." Nachrichten<br>"; echo "<table border='1'><tr><td>Betreff</td><td>Datum</td><td>Absender</td></tr>"; foreach ($overall as $key=>$val) { echo "<tr><td><a href='$PHP_SELF?detail=$key'>".$overall[$key]['subject']."</a></td><td>".date("d.m.Y H:m",$overall[$key]['date'])."</td><td>".$overall[$key]['from']."</td></tr>"; } echo "</table><br>"; if ($detail) { // Gibt den Message - Body mit Attachements zurück: $msg=$boMail->getDetail($detail); } // schließt Connection: $boMail->disconnect(); /* ------------------------------------------------------- KLASSE boMail: */ class boMail { var $box; /** mailbox - Reverence */ var $mailbox; /** Mailbox Host & Postfach */ var $user; /** POP oder SMTP - user */ var $pw; /** POP oder SMTP - password */ var $connected; /** Is connected? */ var $mailsnum; /** Anzahl der Emails im postfach */ var $msgno; /** Aktuelle msgno für detail */ var $mail=array(); /** mail - Details */ var $isHTML=false; /** ist HTML part vorhanden? */ var $types=array("text","multipart","message","application","audio","image","video","other"); var $encodings=array("7BIT","8BIT","BINERY","BASE64","QUOTED-PRINTABLE","OTHER"); function boMail( $user , $pw , $postfach="INBOX" , $host="localhost" , $port="pop3:110") { $this->mailbox="{".$host."/".$port."}".$postfach; $this->user=$user; $this->pw=$pw; return $this->connect(); } function connect() { if ($this->box = @imap_open( $this->mailbox , $this->user , $this->pw )) { $this->connected=true; $this->mailsnum = imap_num_msg($this->box); return 1; } else { $this->echoError("Konnte keine Verbindung aufbauen!<br>".imap_last_error()); return 0; } } function disconnect() { if ($this->connected) { imap_close($this->box); $this->connected=fasle; } } function getOverview() { if ($overview = imap_fetch_overview ($this->box,$this->mailsnum.":1")) { foreach ($overview as $key=>$val) { $head=imap_header($this->box,$val->msgno); $ret[$val->msgno]["from"]=$head->fromaddress; $elements=imap_mime_header_decode($head->subject); for($i=0;$i<count($elements);$i++) { $subject=$elements[$i]->text; } $ret[$val->msgno]["subject"]=$subject; $ret[$val->msgno]["date"]=$head->udate; $ret[$val->msgno]["size"]=$val->size; $flags=$head->Recent.$head->Unseen.$head->Answered.$head->Deleted.$head->Draft.$head->Flagged; $ret[$val->msgno]["flags"]=$flags; } return $ret; }//<-if } function getDetail($msgno) { $this->msgno=$msgno; $structure = imap_fetchstructure($this->box,$this->msgno); $type=$this->types[$structure->type]; $parts=$structure->parts; $this->parseparts($parts,$type,$structure->subtype); } function parseparts($parts,$type,$subtype) { if (!empty($parts)) { for ($i=(count($parts)-1);$i>=0;$i--) { if ($parts[$i]->parts) { $this->parseparts($parts[$i]->parts , $this->types[$parts[$i]->type] , $parts[$i]->subtype ); } $filename=$parts[$i]->parameters[0]->value; $this->getPart($i+1 , $this->types[($parts[$i]->type)] , $parts[$i]->subtype , $this->encodings[$parts[$i]->encoding] , $filename); } } else { $this->getPart(1 , $type , $subtype , $encoding); } } function getPart($pid,$type,$subtype,$encoding,$filename="") { if (strtolower($subtype)=="html") $this->isHTML=1; $body=imap_fetchbody($this->box,$this->msgno,$pid); if ($encoding=="QUOTED-PRINTABLE" || empty($encoding)) $body=quoted_printable_decode($body); if ($type=="text") { if (strtolower($subtype)=="html") { echo html_entity_decode($body); } else if (!$this->isHTML) { echo nl2br($body); //$this->mail['body'].= imap_fetchbody($this->box,$this->msgno,$pid); $this->isHTML=0; } } else if ($type=="image") { echo "<br>BILD: <img src='".$this->mkAttachement($filename,$encoding,$body)."'>"; } else if ($type=="application") { $f=$this->mkAttachement($filename,$encoding,$body); echo "<br>APPLICATION: <a href='$f'>$f</a>"; } else { echo "<B><I>Unbekanntes Format </i>$type/$subtype</b><br>"; } } function mkAttachement($filename,$decode,$data) { $fh=fopen($filename,"w"); if ($decode=="BASE64") $data=imap_base64($data); fwrite($fh,$data); fclose($fh); return $filename; } function umlaute($text) { $text=imap_8bit($text); $uml=array("=3DE4"=>"ä" , "=3DC4"=>"Ä" , "=3DFC"=>"ü" , "=3DDC"=>"Ü" , "=3DF6"=>"oe" , "=3DD6"=>"Ö" , "=3DDF"=>"ß" , "=3D20"=>" "); foreach ($uml as $code=>$u) { $text=str_replace($code,$u,$text); } return ($text); } function echoError($er) { echo "<div style='background:darkred;color:white'><b>$er</b></div>"; } } ?> </body> </html>
aber er logt sich nich ein? was ist der fehler? -
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage