Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* connect to gmail */
- $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
- $username = 'example_email_address@gmail.com' ;
- $password = 'password';
- /* 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);
- $message = imap_fetchbody($inbox,$email_number,2);
- // $regex = '/b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]/i';
- // preg_match_all($regex, $message, $matches);
- // $urls = $matches[0];
- // // go over all links
- // foreach($urls as $url)
- // {
- // echo $url.'<br />';
- // }
- // $dom = new DOMDocument;
- // //$dom->loadXML($message);
- // $dom->loadHTML($message);
- // $anchortags = $dom->getElementsByTagName('a');
- // foreach ($anchortags as $anchortag) {
- // echo $anchortag->nodeValue, PHP_EOL;
- // preg_match('//([w_-]+(?:(?:.[w_-]+)+))([w.,@?^=%&:/~+#-]*[w@?^=%&/~+#-])?', $anchortag, $matches);
- // }
- // /* output the email header information */
- // $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
- // $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
- // $output.= '<span class="from">'.$overview[0]->from.'</span>';
- // $output.= '<span class="date">on '.$overview[0]->date.'</span>';
- // $output.= '</div>';
- // /* output the email body */
- // $output.= '<div class="body">'.$message.'</div>';
- }
- echo $output;
- }
- function get_data($url) {
- $ch = curl_init();
- $timeout = 5;
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- $returned_content = get_data('https://dash-jci.s3.amazonaws.com/February_11_2017/Feb_11_2017-1486798132143.zip?response-cache-control=max-age%3D31536000&response-content-type=application%2Fzip&AWSAccessKeyId=AKIAJREL4U5PR4NTGPKA&Expires=2135333220&Signature=8FxLAICc89HQMc98LQH6dsIYyp4%3Dfff');
- /* close the connection */
- imap_close($inbox);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement