Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /* connect to gmail */
- set_time_limit(0);
- $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
- $username = 'want.unban@gmail.com';
- $password = 'fencer123';
- /* 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);
- $i = 0;
- /* for every email... */
- foreach ($emails as $email_number) {
- /* get information specific to this email */
- $overview = imap_fetch_overview($inbox,$email_number,0);
- $message = imap_fetchbody($inbox,$email_number,2);
- if (strpos(strtolower($message),'//z') === false AND strpos(strtolower($message),'///') === false AND strpos(strtolower($message),'aaa') === false AND strpos(strtolower($message),'/w') === false) {
- $ar[strtotime($overview[0]->date)]['subject'] = $overview[0]->subject;
- $ar[strtotime($overview[0]->date)]['from'] = $overview[0]->from;
- $ar[strtotime($overview[0]->date)]['message'] = str_replace(array('=20','= ='),'',preg_replace('/\s+/',' ',trim(strip_tags($message))));
- }
- $i++;
- }
- file_put_contents('emails.txt',serialize($ar));
- echo 'hotovo';
- }
- /* close the connection */
- imap_close($inbox);
Add Comment
Please, Sign In to add comment