public function testPop3MessageSourceFetchAll() { $transport = new ezcMailPop3Transport("mta1.ez.no"); $transport->authenticate("*****@*****.**", "ezcomponents"); $parser = new ezcMailParser(); $set = new ezcMailStorageSet($transport->fetchAll(), $this->tempDir); $mail = $parser->parseMail($set); $files = $set->getSourceFiles(); $source = file_get_contents($files[0]); $this->assertEquals(self::$sizes[0], strlen($source)); }
<?php require_once 'tutorial_autoload.php'; // Create a new POP3 transport with a plain connection (default port is 110, // you can specify a different one using the second parameter of the constructor). // A timeout option is specified to be 10 seconds (default is 5). // Another option to be specified is the authenticationMethod as APOP (default is plain text) $options = new ezcMailPop3TransportOptions(); $options->timeout = 10; $options->authenticationMethod = ezcMailPop3Transport::AUTH_APOP; $pop3 = new ezcMailPop3Transport("pop3.example.com", null, $options); // Authenticate to the POP3 server $pop3->authenticate("user", "password");
public function testServerSSL() { if (!ezcBaseFeatures::hasExtensionSupport('openssl')) { $this->markTestSkipped(); } $pop3 = new ezcMailPop3Transport(self::$serverSSL, null, array('ssl' => true)); $pop3->authenticate(self::$userSSL, self::$passwordSSL); $set = $pop3->fetchAll(); $parser = new ezcMailParser(); $mail = $parser->parseMail($set); $mail = $mail[0]; $this->assertEquals(240, $mail->size); }
<?php require_once "extension/jaj_newsletter/lib/bounce_handler/bounce_driver.class.php"; $server = "zmail-01.hikt.no"; $username = "******"; $password = "******"; $bouncehandler = new Bouncehandler(); $pop3 = new ezcMailPop3Transport($server); $pop3->authenticate($username, $password); $pop3->status($num, $size); $cli->output('Bounce messages to check: ' . $num); $messages = $pop3->listMessages(); foreach ($messages as $index => $size) { $set = $pop3->fetchByMessageNr($index); do { $raw_message = ""; $line = ""; while (($line = $set->getNextLine()) !== null) { $raw_message .= $line; } $result = $bouncehandler->get_the_facts($raw_message); $result = $result[0]; $status = $result['status']; $action = $result['action']; $recipient = trim($result['recipient']); if (!in_array($action, array("delayed", "failed", "autoreply"))) { $cli->output("Message index: {$index}, unknown action: {$action}, skipping..."); continue; } if ($action == 'delayed' || $action == 'autoreply') { $cli->output("Deleting message: {$index}, action: {$action}");
/** * connect with mailaccount * * @return object / boolean */ public function connect() { // current mailbox id $mailboxId = $this->attribute('id'); // current mailbox type, for pop3-/imap switch $mailboxType = $this->attribute('type'); // login data $server = $this->attribute('server'); $userName = $this->attribute('user_name'); $password = $this->attribute('password'); $port = $this->attribute('port'); $ssl = (bool) $this->attribute('is_ssl'); $deleteMailsFromServer = (bool) $this->attribute('delete_mails_from_server'); if ($port > 0) { $serverPort = $port; } else { // let choose ezc the right port if not set $serverPort = null; } $ezcTransportObject = null; $settingArray = array('mailbox_id' => $mailboxId, 'type' => $mailboxType, 'server' => $server, 'user_name' => $userName, 'password' => $password, 'port' => $port, 'is_ssl' => $ssl, 'delete_mails_from_server' => $deleteMailsFromServer); try { // create transport object switch ($mailboxType) { case 'imap': $options = new ezcMailImapTransportOptions(); $options->ssl = $ssl; $options->timeout = 3; $ezcTransportObject = new ezcMailImapTransport($server, $serverPort, $options); break; case 'pop3': $options = new ezcMailPop3TransportOptions(); $options->ssl = $ssl; $options->timeout = 3; // $options->authenticationMethod = ezcMailPop3Transport::AUTH_APOP; $ezcTransportObject = new ezcMailPop3Transport($server, $serverPort, $options); break; default: CjwNewsletterLog::writeError('CjwNewsletterMailbox::connect', 'mailbox', 'connect-failed', array('error-code' => $e->getMessage())); return $e->getMessage(); } } catch (Exception $e) { CjwNewsletterLog::writeError('authenticate ezcMailTransport CjwNewsletterMailbox::connect', 'mailbox', 'connect-failed', array('error-code' => $e->getMessage())); return $e->getMessage(); } try { // authenticate twise is not allowed $ezcTransportObject->authenticate($userName, $password); } catch (Exception $e) { CjwNewsletterLog::writeError('CjwNewsletterMailbox::connect', 'mailbox', 'authenticate-failed', array_merge(array('error-code' => $e->getMessage()), $settingArray)); return $e->getMessage(); } try { switch ($mailboxType) { case 'imap': $ezcTransportObject->selectMailbox('Inbox'); break; } $this->TransportObject = $ezcTransportObject; // set connect time $this->setAttribute('last_server_connect', time()); $this->store(); CjwNewsletterLog::writeDebug('CjwNewsletterMailbox::connect', 'mailbox', 'connect-ok', $settingArray); return $ezcTransportObject; } catch (Exception $e) { CjwNewsletterLog::writeError('CjwNewsletterMailbox::connect', 'mailbox', 'selectBox-failed', array('error-code' => $e->getMessage())); return $e->getMessage(); } }