Created
September 19, 2017 16:44
-
-
Save caionorder/b901048ae079df9414eac70bd905ca20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); | |
DEFINE('SERVIDOR', 'dominio.com.br'); | |
DEFINE('PORTA', '143'); | |
DEFINE('USUARIO', '[email protected]'); | |
DEFINE('SENHA', 'senha'); | |
/* connect to gmail */ | |
$hostname = '{'.SERVIDOR.':'.PORTA.'/imap/novalidate-cert}INBOX.Sent'; | |
$username = USUARIO; | |
$password = SENHA; | |
/* try to connect */ | |
$inbox = imap_open($hostname,$username ,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); | |
/* grab emails */ | |
$emails = imap_search($inbox,'ALL'); | |
/* if emails are returned, cycle through each... */ | |
if($emails) { | |
/* begin output var */ | |
$output = ''; | |
/* put the newest emails on top */ | |
rsort($emails); | |
/* for every email... */ | |
foreach($emails as $email_number) { | |
/* get information specific to this email */ | |
$overview = imap_fetch_overview($inbox,$email_number,0); | |
// echo "<pre>"; | |
// print_r($overview); | |
// $output.= 'Name: '.$overview[0]->from.'</br>'; | |
$output.= 'Email: '.$overview[0]->message_id.'</br>'; | |
} | |
echo $output; | |
} | |
/* close the connection */ | |
imap_close($inbox); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment