asworm Posted June 18, 2009 at 02:43 PM Report Share #273370 Posted June 18, 2009 at 02:43 PM malta isto é o seguinte preciso que o php me abra a milha inbox do GMAIL e me mostre as mensagens... estou farto de procurar, e acho alguns codigos mas nenhum deles funca.. alguem ja fez alguma coisa do genero? <?php $mbox = imap_open("{imap.example.org:143}", "username", "password"); echo "<h1>Mailboxes</h1>\n"; $folders = imap_listmailbox($mbox, "{imap.example.org:143}", "*"); if ($folders == false) { echo "Call failed<br />\n"; } else { foreach ($folders as $val) { echo $val . "<br />\n"; } } echo "<h1>Headers in INBOX</h1>\n"; $headers = imap_headers($mbox); if ($headers == false) { echo "Call failed<br />\n"; } else { foreach ($headers as $val) { echo $val . "<br />\n"; } } imap_close($mbox); ?> tenho aqui este codigo... mas diz-me que a função nao foi declarada... Got it? Link to comment Share on other sites More sharing options...
cyclop Posted June 18, 2009 at 06:57 PM Report Share #273427 Posted June 18, 2009 at 06:57 PM http://pt.php.net/manual/en/imap.requirements.php "Quando eu for grande quero ser como o Celso" Link to comment Share on other sites More sharing options...
infopc Posted June 19, 2009 at 12:48 AM Report Share #273520 Posted June 19, 2009 at 12:48 AM ou então http://phpmailer.codeworxtech.com/index.php O que não tem solução, solucionado esta... Link to comment Share on other sites More sharing options...
asworm Posted June 19, 2009 at 02:25 PM Author Report Share #273619 Posted June 19, 2009 at 02:25 PM <?php // Main ReciveMail Class File - Version 1.1 (02-06-2009) /* * File: recivemail.class.php * Description: Reciving mail With Attechment * Version: 1.1 * Created: 01-03-2006 * Modified: 02-06-2009 * Author: Mitul Koradia * Email: mitulkoradia@gmail.com * Cell : +91 9825273322 */ /***************** Changes ********************* * * 1) Added feature to retrive embedded attachment - Changes provided by. Antti <anttiantti83@gmail.com> * 2) Added SSL Supported mailbox. * **************************************************/ class receiveMail { var $server=''; var $username=''; var $password=''; var $marubox=''; var $email=''; function receiveMail($username,$password,$EmailAddress,$mailserver='pop.gmail.com',$servertype='pop3',$port='995',$ssl = true) //Constructure { if($servertype=='imap') { if($port=='') $port='143'; $strConnect='{'.$mailserver.':'.$port. '}INBOX'; } else { $strConnect='{'.$mailserver.':'.$port. '/pop3'.($ssl ? "/ssl" : "").'}INBOX'; } $this->server = $strConnect; $this->username = $username; $this->password = $password; $this->email = $EmailAddress; } function connect() //Connect To the Mail Box { $this->marubox=@imap_open($this->server,$this->username,$this->password); if(!$this->marubox) { echo "Error: Connecting to mail server"; echo $this->marubox; echo "Error: Connecting to mail server"; exit; } } function getHeaders($mid) // Get Header info { if(!$this->marubox) return false; $mail_header=imap_header($this->marubox,$mid); $sender=$mail_header->from[0]; $sender_replyto=$mail_header->reply_to[0]; if(strtolower($sender->mailbox)!='mailer-daemon' && strtolower($sender->mailbox)!='postmaster') { $mail_details=array( 'from'=>strtolower($sender->mailbox).'@'.$sender->host, 'fromName'=>$sender->personal, 'toOth'=>strtolower($sender_replyto->mailbox).'@'.$sender_replyto->host, 'toNameOth'=>$sender_replyto->personal, 'subject'=>$mail_header->subject, 'to'=>strtolower($mail_header->toaddress) ); } return $mail_details; } function get_mime_type(&$structure) //Get Mime type Internal Private Use { $primary_mime_type = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER"); if($structure->subtype) { return $primary_mime_type[(int) $structure->type] . '/' . $structure->subtype; } return "TEXT/PLAIN"; } function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) //Get Part Of Message Internal Private Use { if(!$structure) { $structure = imap_fetchstructure($stream, $msg_number); } if($structure) { if($mime_type == $this->get_mime_type($structure)) { if(!$part_number) { $part_number = "1"; } $text = imap_fetchbody($stream, $msg_number, $part_number); if($structure->encoding == 3) { return imap_base64($text); } else if($structure->encoding == 4) { return imap_qprint($text); } else { return $text; } } if($structure->type == 1) /* multipart */ { while(list($index, $sub_structure) = each($structure->parts)) { if($part_number) { $prefix = $part_number . '.'; } $data = $this->get_part($stream, $msg_number, $mime_type, $sub_structure, $prefix . ($index + 1)); if($data) { return $data; } } } } return false; } function getTotalMails() //Get Total Number off Unread Email In Mailbox { if(!$this->marubox) return false; $headers=imap_headers($this->marubox); return count($headers); } function GetAttach($mid,$path) // Get Atteced File from Mail { if(!$this->marubox) return false; $struckture = imap_fetchstructure($this->marubox,$mid); $ar=""; if($struckture->parts) { foreach($struckture->parts as $key => $value) { $enc=$struckture->parts[$key]->encoding; if($struckture->parts[$key]->ifdparameters) { $name=$struckture->parts[$key]->dparameters[0]->value; $message = imap_fetchbody($this->marubox,$mid,$key+1); if ($enc == 0) $message = imap_8bit($message); if ($enc == 1) $message = imap_8bit ($message); if ($enc == 2) $message = imap_binary ($message); if ($enc == 3) $message = imap_base64 ($message); if ($enc == 4) $message = quoted_printable_decode($message); if ($enc == 5) $message = $message; $fp=fopen($path.$name,"w"); fwrite($fp,$message); fclose($fp); $ar=$ar.$name.","; } // Support for embedded attachments starts here if($struckture->parts[$key]->parts) { foreach($struckture->parts[$key]->parts as $keyb => $valueb) { $enc=$struckture->parts[$key]->parts[$keyb]->encoding; if($struckture->parts[$key]->parts[$keyb]->ifdparameters) { $name=$struckture->parts[$key]->parts[$keyb]->dparameters[0]->value; $partnro = ($key+1).".".($keyb+1); $message = imap_fetchbody($this->marubox,$mid,$partnro); if ($enc == 0) $message = imap_8bit($message); if ($enc == 1) $message = imap_8bit ($message); if ($enc == 2) $message = imap_binary ($message); if ($enc == 3) $message = imap_base64 ($message); if ($enc == 4) $message = quoted_printable_decode($message); if ($enc == 5) $message = $message; $fp=fopen($path.$name,"w"); fwrite($fp,$message); fclose($fp); $ar=$ar.$name.","; } } } } } $ar=substr($ar,0,(strlen($ar)-1)); return $ar; } function getBody($mid) // Get Message Body { if(!$this->marubox) return false; $body = $this->get_part($this->marubox, $mid, "TEXT/HTML"); if ($body == "") $body = $this->get_part($this->marubox, $mid, "TEXT/PLAIN"); if ($body == "") { return ""; } return $body; } function deleteMails($mid) // Delete That Mail { if(!$this->marubox) return false; imap_delete($this->marubox,$mid); } function close_mailbox() //Close Mail Box { if(!$this->marubox) return false; imap_close($this->marubox,CL_EXPUNGE); } } ?> vejam este codigo... digam-me o que preciso de mudar, ou quais as configurações que preciso de fazer para ir buscar os emails a minhainbox do gmail.... Got it? Link to comment Share on other sites More sharing options...
djthyrax Posted June 19, 2009 at 08:13 PM Report Share #273692 Posted June 19, 2009 at 08:13 PM Vê lá se isto não serve: http://www.phpclasses.org/browse/package/3516.html Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now