예제 #1
0
 public function index()
 {
     $check_email = new Imap();
     $messages = $check_email->get_messages();
     // Close Connection
     $check_email->close();
     // Add Messages
     $this->add_email($messages);
 }
예제 #2
0
파일: ImapTest.php 프로젝트: jyxo/php
 /**
  * Tests working connection.
  */
 public function testAllOk()
 {
     // Skip the test if no IMAP connection is defined
     if (empty($GLOBALS['imap']) || !preg_match('~^([^:]+):([^@]+)@([^:]+):(\\d+)$~', $GLOBALS['imap'], $matches)) {
         $this->markTestSkipped('Imap not set');
     }
     list($user, $password, $host, $port) = array_slice($matches, 1);
     $test = new Imap('Imap', $host, $user, $password, $port, false);
     $result = $test->run();
     $this->assertEquals(\Jyxo\Beholder\Result::SUCCESS, $result->getStatus());
     $this->assertEquals(sprintf('%s@%s:%s', $user, $host, $port), $result->getDescription());
 }
예제 #3
0
 /**
  * This constructor takes in the uid for the message and the Imap class representing the mailbox the
  * message should be opened from. This constructor should generally not be called directly, but rather retrieved
  * through the apprioriate Imap functions.
  *
  * @param int $message_unique_id
  * @param Imap $mailbox
  */
 public function __construct($message_unique_id, Imap $mailbox)
 {
     $this->imap_connection = $mailbox;
     $this->uid = $message_unique_id;
     $this->imap_stream = $this->imap_connection->get_imap_stream();
     $this->load_message();
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 protected function setExtHeaders(&$headers, array $data)
 {
     parent::setExtHeaders($headers, $data);
     $headers->addHeaderLine(self::X_GM_MSGID, $data[self::X_GM_MSGID]);
     $headers->addHeaderLine(self::X_GM_THRID, $data[self::X_GM_THRID]);
     $headers->addHeaderLine(self::X_GM_LABELS, isset($data[self::X_GM_LABELS]) ? $data[self::X_GM_LABELS] : array());
 }
예제 #5
0
 /**
  * This constructor takes in the uid for the message and the Imap class representing the mailbox the
  * message should be opened from. This constructor should generally not be called directly, but rather retrieved
  * through the apprioriate Imap functions.
  *
  * @param int  $messageUniqueId
  * @param Imap $mailbox
  */
 public function __construct($messageUniqueId, Server $mailbox)
 {
     $this->imapConnection = $mailbox;
     $this->uid = $messageUniqueId;
     $this->imapStream = $this->imapConnection->getImapStream();
     $this->loadMessage();
 }
예제 #6
0
파일: Attachment.php 프로젝트: komex/fetch
 /**
  * This function returns the data of the attachment. Combined with getMimeType() it can be used to directly output
  * data to a browser.
  *
  * @return string
  */
 public function getData()
 {
     if (!isset($this->data)) {
         $message_body = isset($this->part_id) ? $this->imap->fetchBody($this->imap_stream, $this->message_id, $this->part_id, FT_UID) : $this->imap->body($this->imap_stream, $this->message_id, FT_UID);
         $message_body = Message::decode($message_body, $this->encoding);
         $this->data = $message_body;
     }
     return $this->data;
 }
예제 #7
0
 public function index()
 {
     $check_email = new Imap();
     $messages = $check_email->get_messages();
     //Get email messages that have been marked for delete
     $delete = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->join('service', 'reporter.service_id', 'service.id')->where('service.id', 2)->where('message_trash', 1)->find_all();
     //Iterate through the list of messages and delete from mailbox and database respectively
     foreach ($delete as $email) {
         //Delete message from mailbox
         $check_email->delete_message($email->service_messageid);
         //Delete message from database
         ORM::factory('message')->delete($email->id);
     }
     // Close Connection
     $check_email->close();
     // Add Messages
     $this->add_email($messages);
 }
예제 #8
0
 private function findMessage($token)
 {
     $mailbox = new Imap(EMAIL_SERVER, EMAIL_USER, EMAIL_PASSWORD);
     $i = 0;
     do {
         sleep(1);
         $messages = $mailbox->listMessages();
         foreach ($messages as $number => $headers) {
             if (strpos($headers['subject'], $token) !== FALSE) {
                 $message = $mailbox->getMessage($number, TRUE);
                 $mailbox->deleteMessage($number);
                 return $message;
             }
         }
         $i++;
     } while ($i < 60);
     throw new Exception('Email message ' . $token . ' never arrived');
 }
예제 #9
0
 public function index()
 {
     if (extension_loaded('imap')) {
         $email_username = Kohana::config('settings.email_username');
         $email_password = Kohana::config('settings.email_password');
         $email_host = Kohana::config('settings.email_host');
         $email_port = Kohana::config('settings.email_port');
         $email_servertype = Kohana::config('settings.email_servertype');
         if (!empty($email_username) and !empty($email_password) and !empty($email_host) and !empty($email_port) and !empty($email_servertype)) {
             $check_email = new Imap();
             $messages = $check_email->get_messages();
             // Close Connection
             $check_email->close();
             // Add Messages
             $this->add_email($messages);
         } else {
             echo "Email is not configured.<BR /><BR />";
         }
     } else {
         echo "You Do Not Have the IMAP PHP Library installed. Email will not be retrieved.<BR/ ><BR/ >";
     }
 }
예제 #10
0
파일: imap.php 프로젝트: ajturner/ushahidi
 public function index()
 {
     // 'pop3' or 'imap'
     $imap = Imap::factory('imap');
     $messages = $imap->get_messages();
     //FIXME: use ORM relationships
     foreach ($messages as $message) {
         $location = ORM::factory('location');
         $location->location_date = $message['date'];
         $location->save();
         $incident = ORM::factory('incident');
         $incident->location_id = $location->id;
         $incident->incident_title = $message['subject'];
         $incident->incident_date = $message['date'];
         $incident->incident_description = $message['body'];
         $incident->incident_mode = 3;
         $incident->save();
         $incident_person = ORM::factory('incident_person');
         $incident_person->incident_id = $incident->id;
         $incident_person->person_email = $message['from'];
         $incident_person->save();
     }
 }
예제 #11
0
파일: inbox.php 프로젝트: gshpci/websms
    /*width: calc(100% - 20px);*/
    padding: 0 2.5em 0 2.5em;
    width: 100%;
    color: black;
  }
</style>

<?php 
require_once "Imap.php";
$mailbox = CONF_WEBHOST . ':993';
$username = CONFG_IMAP_USER;
$password = CONFG_PASSWORD;
$encryption = 'ssl';
// or ssl or ''
// open connection
$imap = new Imap($mailbox, $username, $password, $encryption);
// stop on error
if ($imap->isConnected() === false) {
    die($imap->getError());
}
// get all folders as array of strings
//$folders = $imap->getFolders();
//foreach($folders as $folder)
//    echo $folder.'<br>';
// select folder Inbox
$imap->selectFolder('INBOX');
// count messages in current folder
$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();
//echo "Message Count: ".$overallMessages." | ".$unreadMessages."<br>";
// fetch all messages in the current folder
예제 #12
0
<?php

require_once "Imap.php";
$mailbox = 'my.imapserver.com';
$username = '******';
$password = '******';
$encryption = 'tls';
// or ssl or ''
// open connection
$imap = new Imap($mailbox, $username, $password, $encryption);
// stop on error
if ($imap->isConnected() === false) {
    die($imap->getError());
}
// get all folders as array of strings
$folders = $imap->getFolders();
foreach ($folders as $folder) {
    echo $folder;
}
// select folder Inbox
$imap->selectFolder('INBOX');
// count messages in current folder
$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();
// fetch all messages in the current folder
$emails = $imap->getMessages();
var_dump($emails);
// add new folder for archive
$imap->addFolder('archive');
// move the first email to archive
$imap->moveMessage($emails[0]['id'], 'archive');
예제 #13
0
require_once '../phpscripts/EmailReader.php';
error_reporting(E_ERROR);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
?>


<?php 
$mailbox = 'webmail.johnsonfinancialservice.com';
$username = '******';
$password = '******';
$encryption = 'tls';
// or ssl or '';
$imap = new Imap($mailbox, $username, $password, $encryption);
if ($imap->isConnected() === false) {
    die($imap->getError());
}
$folders = $imap->getFolders();
// returns array of strings
foreach ($folders as $folder) {
    //echo $folder;
}
$imap->selectFolder("INBOX");
$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();
//echo "<br>";
//echo $overallMessages;
//echo "<br>";
//echo $unreadMessages;
 function cacheAttachments(&$msg_no, &$parts, $breadcrumb = '0', $file_attachment)
 {
     foreach ($parts as $k => $part) {
         $this_breadcrumb = $k + 1;
         if ($breadcrumb != '0') {
             $this_breadcrumb = $breadcrumb . '.' . $this_breadcrumb;
         }
         if (isset($part->parts) && !empty($part->parts)) {
             $this->cacheAttachments($msg_no, $part->parts, $this_breadcrumb, $file_attachment);
         } else {
             if ($part->ifdisposition) {
                 if (strtolower($part->disposition) == 'attachment' || strtolower($part->disposition) == 'inline' && $part->type != 0) {
                     $filename = Imap::handleEncodedFilename($part->dparameters[0]->value);
                     $attachment_name = $file_attachment . '-' . $this_breadcrumb . '.php';
                     $msg_part_raw = imap_fetchbody($this->_inbox->conn, $msg_no, $this_breadcrumb);
                     $msg_part = Imap::handleTranserEncoding($msg_part_raw, '3');
                     if ($h = fopen($attachment_name, 'wb')) {
                         fwrite($h, $msg_part);
                         fclose($h);
                     }
                 }
             }
         }
     }
 }
예제 #15
0
파일: index.php 프로젝트: clops/mail-screen
<?php

require_once 'init.inc.php';
require_once "lib/Imap.php";
$mailbox = config::get()->imap_host;
$username = config::get()->imap_user;
$password = config::get()->imap_password;
$encryption = config::get()->imap_encryption;
// or ssl or ''
// open connection
$imap = new Imap($mailbox, $username, $password, $encryption);
// stop on error
if ($imap->isConnected() === false) {
    die($imap->getError());
}
// get all folders as array of strings
$folders = $imap->getFolders();
foreach ($folders as $folder) {
    echo $folder;
}
예제 #16
0
	/**
	 * Abre a caixa de correio
	 * @throws	ImapException Caso algum erro de conexão ocorra
	 */
	public function open() {
		$this->imap->open( $this->fullname );
	}
예제 #17
0
파일: Server.php 프로젝트: komex/fetch
 /**
  * Creates the given mailbox.
  *
  * @param string $mailbox
  */
 public function createMailBox($mailbox)
 {
     $this->imap->createMailbox($this->getImapStream(), $this->getServerSpecification() . $mailbox);
 }
예제 #18
0
 /**
  * Returns Mail IMAP
  *
  * @param string
  * @param string
  * @param string
  * @param int|null
  * @param bool
  * @param bool
  *
  * @return Eden\Mail\Imap
  */
 public function imap($host, $user, $pass, $port = null, $ssl = false, $tls = false)
 {
     Argument::i()->test(1, 'string')->test(2, 'string')->test(3, 'string')->test(4, 'int', 'null')->test(5, 'bool')->test(6, 'bool');
     return Imap::i($host, $user, $pass, $port, $ssl, $tls);
 }
예제 #19
0
 /**
  * @param $mid
  * @param $p
  * @param $part
  */
 private static function getPart($mid, $p, $part)
 {
     $data = $part ? imap_fetchbody(self::$mbox, $mid, $part) : imap_body(self::$mbox, $mid);
     if ($p->encoding == 4) {
         $data = quoted_printable_decode($data);
     } elseif ($p->encoding == 3) {
         $data = base64_decode($data);
     }
     $params = array();
     if ($p->parameters) {
         foreach ($p->parameters as $x) {
             $params[strtolower($x->attribute)] = $x->value;
         }
     }
     if ($p->dparameters) {
         foreach ($p->dparameters as $x) {
             $params[strtolower($x->attribute)] = $x->value;
         }
     }
     if ($params['filename'] || $params['name']) {
         $filename = $params['filename'] ? $params['filename'] : $params['name'];
         if (self::$attachments[$filename]) {
             self::$attachments[time() . '_' . $filename] = $data;
         } else {
             self::$attachments[$filename] = $data;
         }
     } elseif ($p->type == 0 && $data) {
         if (strtolower($p->subtype) == 'plain') {
             self::$plainmsg .= trim($data) . "\n\n";
         } else {
             self::$htmlmsg .= $data . "<br><br>";
         }
         self::$charset = $params['charset'];
     } elseif ($p->type == 2 && $data) {
         self::$plainmsg .= trim($data) . "\n\n";
     }
     if ($p->parts) {
         foreach ($p->parts as $partno => $p2) {
             self::getpart($mid, $p2, $part . '.' . ($partno + 1));
         }
     }
 }
예제 #20
0
/**
 * 
 * @param type $encryptedPassword
 * @param type $rsaTime
 * @return boolean
 */
function authSteam($encryptedPassword, $rsaTime, $debug = false)
{
    include_once _SYSDIR_ . 'private/libs/phpseclib/Math/BigInteger.php';
    include_once _SYSDIR_ . 'private/libs/phpseclib/Crypt/RSA.php';
    include_once _SYSDIR_ . 'system/inc/Imap.php';
    $login = STEAM_LOGIN;
    $password = STEAM_PASSWORD;
    $cookies = _SYSDIR_ . 'private/cookies/cookies.txt';
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Auth manager loaded. Sleeping for 10 s." . "\n";
    }
    sleep(10);
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Opening IMAP." . "\n";
    }
    if (!Imap::open(EMAIL_IMAP, EMAIL_USERNAME, EMAIL_PASSWORD)) {
        //connection to emailbox
        return false;
    }
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Opened. Ping Steam." . "\n";
    }
    if (!geturl("https://steamcommunity.com", null, $cookies, null, 0, $info)) {
        //ping Steam
        return false;
    }
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Steam accessible." . "\n";
    }
    if (!$encryptedPassword) {
        return false;
    }
    $captchaGid = -1;
    $emailSteamId = null;
    $captchaText = null;
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Searching list on email server via IMAP." . "\n";
    }
    Imap::search('BODY "Steam Guard code"');
    //Imap::search('ALL');
    $array = Imap::getMail();
    $codes = array();
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Found " . count($array) . " emails in INBOX." . "\n";
    }
    foreach ($array as $row) {
        //if ($row['from'] == '*****@*****.**') {
        //if (preg_match("/Here\'s the Steam Guard code you\'ll need to complete the process\:/", $row['plain'])) {
        if (preg_match("/need to complete the process\\:/", $row['plain'])) {
            if (preg_match("/\\<h2\\>([A-Z0-9]{5})\\<\\/h2\\>/", $row['html'], $code)) {
                $codes[strtotime($row['date'])] = $code[1];
            }
        }
        //}
    }
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Found " . count($codes) . " codes in INBOX." . "\n";
        echo "\n";
        var_dump($codes);
        echo "\n";
        echo "\n";
    }
    if ($codes && count($codes) > 0) {
        if (krsort($codes)) {
            $emailAuth = $codes[key($codes)];
        }
    }
    if (!$emailAuth) {
        return false;
    }
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Found last code - " . $emailAuth . "." . "\n";
    }
    $params = array('username' => $login, 'password' => $encryptedPassword, 'rsatimestamp' => $rsaTime, 'captcha_gid' => $captchaGid, 'captcha_text' => $captchaText, 'emailauth' => $emailAuth, 'emailsteamid' => $emailSteamId);
    if ($debug) {
        echo "[" . date("H:i:s") . "] " . "Sending AUTH CODE to Steam." . "\n";
    }
    $output = geturl("https://steamcommunity.com/login/dologin/", null, $cookies, $params, 0, $info);
    $data = json_decode($output, true);
    if ($data['captcha_needed']) {
        return false;
    } else {
        if ($data['success'] && $data['login_complete']) {
            $output = geturl($data['transfer_url'], null, $cookies, $data['transfer_parameters'], 0, $info);
            //ping Steam
            return true;
        } elseif (!$data['login_complete']) {
            if (!$data['success'] && $data['emailauth_needed']) {
                return false;
            }
            //authSteam($encryptedPassword, $rsaTime);
        }
    }
    return false;
}
예제 #21
0
파일: Message.php 프로젝트: komex/fetch
 /**
  * This function is used to move a mail to the given mailbox.
  *
  * @param $mailbox
  */
 public function moveToMailBox($mailbox)
 {
     $this->imap->mailCopy($this->imap_stream, $this->uid, $mailbox, CP_UID | CP_MOVE);
 }
예제 #22
0
<?php
require 'dso/mail/imap/exception/ImapException.php';
require 'dso/mail/imap/Imap.php';

$username = '******';
$password = '******';

if ( $username == '*****@*****.**' && $password == 'senha' ) {
	throw new Exception( 'Defina o usuário e senha antes de executar o exemplo' );
} else {
	try {
		$imap = new Imap();
		$imap->open( '{imap.gmail.com:993/imap/ssl/novalidate-cert}' , $username , $password );

		for ( $mbi = $imap->getMailboxIterator() ; $mbi->valid() ; $mbi->next() ) {
			$mailbox = $mbi->current();
			$mailbox->open();

			printf( "%s\n" , $mailbox->getName() );

			for ( $mi = $imap->getMessageIterator() ; $mi->valid() ; $mi->next() ) {
				$message = $mi->current();
				$message->fetch();

				printf( "\tID: %s\n" , $message->getMessageId() );
				printf( "\tDe: %s\n" , $message->getFrom() );
				printf( "\tPara: %s\n" , $message->getTo() );
				printf( "\tAssunto: %s\n" , $message->getSubject() );
				printf( "\tData: %s\n\n" , $message->getDate() );
			}