delete() публичный Метод

This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. The message number $msgNum must be a valid identifier fetched with e.g. {@link listMessages()}. The message is not physically deleted, but has its DELETED flag set, and can be later undeleted by clearing its DELETED flag with {@link clearFlag()}. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected.
public delete ( integer $msgNum ) : boolean
$msgNum integer
Результат boolean
Пример #1
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");
 }
Пример #2
0
 public function testExpunge()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port);
     $imap->authenticate(self::$user, self::$password);
     $imap->createMailbox("Guybrush");
     $imap->selectMailbox("Inbox");
     $imap->copyMessages("1:4", "Guybrush");
     $imap->selectMailbox("Guybrush");
     $this->assertEquals(4, $imap->countByFlag("ALL"));
     $imap->delete(1);
     $imap->expunge();
     $this->assertEquals(3, $imap->countByFlag("ALL"));
     $set = $imap->fetchByMessageNr(2, true);
     $parser = new ezcMailParser();
     $mail = $parser->parseMail($set);
     $imap->expunge();
     $this->assertEquals(2, $imap->countByFlag("ALL"));
     $imap->selectMailbox("Inbox");
     $imap->deleteMailbox("Guybrush");
 }
Пример #3
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;
 }
Пример #4
0
// Fetch one message from the server (here: get the message no. 2)
$set = $imap->fetchByMessageNr(2);
// Fetch a range of messages from the server (here: get 4 messages starting from message no. 2)
$set = $imap->fetchFromOffset(2, 4);
// Fetch messages which have a certain flag
// See the function description for a list of supported flags
$set = $imap->fetchByFlag("DELETED");
// Fetch a range of messages sorted by Date
// Use this to page through a mailbox
// See the function description for a list of criterias and for how to sort ascending or descending
$set = $imap->sortFromOffset(1, 10, "Date");
// Sort the specified messages by Date
// See the function description for a list of criterias and for how to sort ascending or descending
$set = $imap->sortMessages("1,2,3,4,5", "Date");
// Fetch messages which match the specified criteria.
// See the section 6.4.4. of RFC 1730 or 2060 for a list of criterias
// (http://www.faqs.org/rfcs/rfc1730.html)
// The following example returns the messages flagged as SEEN and with
// 'release' in their Subject
$set = $imap->searchMailbox('SEEN SUBJECT "release"');
// Delete a message from the server (message is not physically deleted, but it's
// list of flags get the "Deleted" flag.
$imap->delete(1);
// Use this to permanently delete the messages flagged with "Deleted"
$imap->expunge();
// Use this to keep the connection alive
$imap->noop();
// Create a new mail parser object
$parser = new ezcMailParser();
// Parse the set of messages retrieved from the server earlier
$mail = $parser->parseMail($set);