authenticate() 공개 메소드

This method should be called directly after the construction of this object. If the server is waiting for the authentication process to respond, the connection with the IMAP server will be closed, and false is returned, and it is the application's task to reconnect and reauthenticate. Example of creating an IMAP transport and authenticating: replace with your IMAP server address $imap = new ezcMailImapTransport( 'imap.example.com' ); replace the values with your username and password for the IMAP server $imap->authenticate( 'username', 'password' );
public authenticate ( string $user, string $password ) : boolean
$user string
$password string
리턴 boolean
예제 #1
0
<?php

require_once 'tutorial_autoload.php';
// Create a new IMAP transport object by specifying the server name
$imap = new ezcMailImapTransport("imap.example.com");
// Authenticate to the IMAP server
$imap->authenticate("user", "password");
// Select the Inbox mailbox
$imap->selectMailbox('Inbox');
// List the capabilities of the IMAP server
$capabilities = $imap->capability();
// List existing mailboxes
$mailboxes = $imap->listMailboxes("", "*");
// Fetch the hierarchy delimiter character (usually "/")
$delimiter = $imap->getHierarchyDelimiter();
// Create a new mailbox
$imap->createMailbox("Reports 2006");
// Delete a mailbox
$imap->deleteMailbox("Reports 2005");
// Rename a mailbox
$imap->renameMailbox("Reports 2006", "Reports");
// Copy messages from the selected mailbox (here: Inbox) to another mailbox
$imap->copyMessages("1,2,4", "Reports");
// Set a flag to messages
// See the function description for a list of supported flags
$imap->setFlag("1,2,4", "DELETED");
// Clears a flag from messages
// See the function description for a list of supported flags
$imap->clearFlag("1,2,4", "SEEN");
// Append a message to a mailbox. $mail must contain the mail as text
// Use this with a "Sent" or "Drafts" mailbox
예제 #2
0
 public function testUidDelete()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
     $imap->authenticate(self::$user, self::$password);
     $imap->createMailbox("Guybrush");
     $imap->selectMailbox('inbox');
     $imap->copyMessages(self::$ids[0], "Guybrush");
     $imap->selectMailbox("Guybrush");
     $imap->delete(1);
     $imap->selectMailbox('inbox');
     $imap->deleteMailbox("Guybrush");
 }
예제 #3
0
 public function tearDown()
 {
     $this->removeTempDir();
     $transport = new ezcMailImapTransport("mta1.ez.no");
     $transport->authenticate("*****@*****.**", "ezcomponents");
     try {
         $transport->deleteMailbox("Guybrush");
     } catch (ezcMailTransportException $e) {
     }
 }
예제 #4
0
 /**
  * Get the password reset URL.
  *
  * @return string
  */
 public static function getPasswordResetURL()
 {
     $options = new \ezcMailImapTransportOptions();
     $options->ssl = true;
     $imap = new \ezcMailImapTransport('imap.gmail.com', null, $options);
     $imap->authenticate('*****@*****.**', Config::get('kinvey::testMail'));
     $imap->selectMailbox('Inbox');
     $set = $imap->searchMailbox('FROM "*****@*****.**"');
     $parser = new \ezcMailParser();
     $mail = $parser->parseMail($set);
     preg_match("#https.*#", $mail[0]->generateBody(), $matches);
     $url = html_entity_decode($matches[0]);
     $url = mb_substr($url, 0, -1);
     foreach ($set->getMessageNumbers() as $msgNum) {
         $imap->delete($msgNum);
     }
     $imap->expunge();
     return $url;
 }
예제 #5
0
파일: mail.php 프로젝트: notion/zeta-mail
require 'app/paging_links.php';
// Required method to be able to use the eZ Components
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Start counting how much the execution time will be
$start = microtime(true);
// Read configuration file app.ini with the Configuration component
$iniFile = 'app';
$config = ezcConfigurationManager::getInstance();
$config->init('ezcConfigurationIniReader', dirname(__FILE__));
$options = array('templatePath' => dirname(__FILE__) . $config->getSetting($iniFile, 'TemplateOptions', 'TemplatePath'), 'compilePath' => dirname(__FILE__) . $config->getSetting($iniFile, 'TemplateOptions', 'CompilePath'), 'server' => $config->getSetting($iniFile, 'MailOptions', 'Server'), 'user' => $config->getSetting($iniFile, 'MailOptions', 'User'), 'password' => $config->getSetting($iniFile, 'MailOptions', 'Password'), 'mailbox' => isset($_GET['mailbox']) ? $_GET['mailbox'] : $config->getSetting($iniFile, 'MailOptions', 'Mailbox'), 'pageSize' => $config->getSetting($iniFile, 'MailOptions', 'PageSize'), 'currentPage' => isset($_GET['page']) ? $_GET['page'] : null);
// Create a mail IMAP transport object
$transport = new ezcMailImapTransport($options["server"]);
$transport->authenticate($options["user"], $options["password"]);
$transport->selectMailbox($options["mailbox"]);
// Get the mailboxes names from the server
$mailboxes = $transport->listMailboxes();
sort($mailboxes);
// Get the UIDs of the messages in the selected mailbox
// and the sizes of the messages
$mailIDs = $transport->listUniqueIdentifiers();
$messages = $transport->listMessages();
// Calculate how many pages of mails there will be based on pageSize
$numberOfPages = (int) floor(count($messages) / $options["pageSize"] + 1);
// See if currentPage fits in the range 1..numberOfPages
if ($options["currentPage"] <= 0 || $options["currentPage"] > $numberOfPages || count($messages) % $options["pageSize"] === 0 && $options["currentPage"] >= $numberOfPages) {
    $options["currentPage"] = 1;
}
// Slice the array to the range defined by currentPage
예제 #6
0
 /**
  * Test for issue #14360: problems with $imap->top() command in gmail.
  */
 public function testTopGmailHeadersOnly()
 {
     $options = new ezcMailImapTransportOptions();
     $options->ssl = true;
     $imap = new ezcMailImapTransport('imap.gmail.com', '993', $options);
     // please don't use this account :)
     $imap->authenticate('ezcomponents' . '@' . 'gmail.com', 'wee12345');
     $imap->selectMailbox('inbox');
     $text = $imap->top(1, 1);
     $this->assertEquals(382, strlen($text));
 }
예제 #7
0
<?php

require_once '/home/dotxp/dev/PHP/zetacomponents/trunk/Base/src/ezc_bootstrap.php';
require_once 'blog_entry.php';
require_once 'blog_entry_creator.php';
$imapOptions = new ezcMailImapTransportOptions();
$imapOptions->ssl = true;
$imap = new ezcMailImapTransport('example.com', 993, $imapOptions);
$imap->authenticate('*****@*****.**', 'foo23bar');
$imap->selectMailbox('Inbox');
$messageSet = $imap->fetchAll();
$parser = new ezcMailParser();
$mails = $parser->parseMail($messageSet);
$blogEntryCreator = new qaBlogEntryCreator();
foreach ($mails as $mail) {
    $entry = $blogEntryCreator->createEntry($mail);
    $entry->save();
}