本文整理汇总了PHP中ezcMailParser类的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailParser类的具体用法?PHP ezcMailParser怎么用?PHP ezcMailParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcMailParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchNext
/**
* Return the next X messages from the mail store
* FIXME: in CiviCRM 2.2 this always returns all the emails
*
* @param int $count number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all)
*
* @return array array of ezcMail objects
*/
function fetchNext($count = 0)
{
$mails = array();
$path = rtrim($this->_dir, DIRECTORY_SEPARATOR);
if ($this->_debug) {
print "fetching {$count} messages\n";
}
$directory = new DirectoryIterator($path);
foreach ($directory as $entry) {
if ($entry->isDot()) {
continue;
}
if (count($mails) >= $count) {
break;
}
$file = $path . DIRECTORY_SEPARATOR . $entry->getFilename();
if ($this->_debug) {
print "retrieving message {$file}\n";
}
$set = new ezcMailFileSet(array($file));
$parser = new ezcMailParser();
//set property text attachment as file CRM-5408
$parser->options->parseTextAttachmentsAsFiles = TRUE;
$mail = $parser->parseMail($set);
if (!$mail) {
return CRM_Core_Error::createAPIError(ts('%1 could not be parsed', array(1 => $file)));
}
$mails[$file] = $mail[0];
}
if ($this->_debug && count($mails) <= 0) {
print "No messages found\n";
}
return $mails;
}
示例2: fetchNext
/**
* Return the next X messages from the mail store
*
* @param int $count number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all)
*
* @return array array of ezcMail objects
*/
function fetchNext($count = 0)
{
$mails = array();
if ($this->_debug) {
print "fetching {$count} messages\n";
}
$query = "SELECT * FROM mailgun_events WHERE processed = 0 AND ignored = 0";
$query_params = array();
if ($count > 0) {
$query .= " LIMIT %1";
$query_params[1] = array($count, 'Int');
}
$dao = CRM_Core_DAO::executeQuery($query, $query_params);
while ($dao->fetch()) {
$set = new ezcMailVariableSet($dao->email);
$parser = new ezcMailParser();
//set property text attachment as file CRM-5408
$parser->options->parseTextAttachmentsAsFiles = TRUE;
$mail = $parser->parseMail($set);
if (!$mail) {
return CRM_Core_Error::createAPIError(ts('Email ID %1 could not be parsed', array(1 => $dao->id)));
}
$mails[$dao->id] = $mail[0];
}
if ($this->_debug && count($mails) <= 0) {
print "No messages found\n";
}
return $mails;
}
示例3: testFromProcMail
public function testFromProcMail()
{
$mail_msg = file_get_contents(dirname(__FILE__) . '/data/test-variable');
$set = new ezcMailVariableSet($mail_msg);
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
// check that we have no extra linebreaks
$this->assertEquals("notdisclosed@mydomain.com", $mail[0]->from->email);
}
示例4: fetchNext
/**
* Return the next X messages from the mail store
* FIXME: in CiviCRM 2.2 this always returns all the emails
*
* @param int $count number of messages to fetch FIXME: ignored in CiviCRM 2.2 (assumed to be 0, i.e., fetch all)
* @return array array of ezcMail objects
*/
function fetchNext($count = 0)
{
$mails = array();
$parser = new ezcMailParser();
foreach (array('cur', 'new') as $subdir) {
$dir = $this->_dir . DIRECTORY_SEPARATOR . $subdir;
foreach (scandir($dir) as $file) {
if ($file == '.' or $file == '..') {
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $file;
if ($this->_debug) {
print "retrieving message {$path}\n";
}
$set = new ezcMailFileSet(array($path));
$single = $parser->parseMail($set);
$mails[$path] = $single[0];
}
}
return $mails;
}
示例5: createRequest
/**
* Uses stdin, or the provided data in $mailMessage.
*
* @param string $mailMessage
* @return ezcMvcRequest
*/
public function createRequest($mailMessage = null)
{
if ($mailMessage === null) {
$set = new ezcMailFileSet(array("php://stdin"));
} else {
$set = new ezcMailVariableSet($mailMessage);
}
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
if (count($mail) == 0) {
throw new ezcMvcMailNoDataException();
}
$mail = $mail[0];
$this->request = new ezcMvcRequest();
$this->processStandardHeaders($mail);
$this->processAcceptHeaders($mail);
$this->processUserAgentHeaders($mail);
$this->processFiles($mail);
$this->request->raw = $mail;
return $this->request;
}
示例6: parse
/**
* Basics parse
*
* @return array / boolean
*/
public function parse()
{
// parse set to mailobject
$set = new ezcMailVariableSet($this->MailboxItem->getRawMailMessageContent());
try {
$ezcMailObjectArray = $this->MailParser->parseMail($set);
} catch (Exception $e) {
CjwNewsletterLog::writeError('CjwNewsletterMailparser::parse', 'parseMail', 'ezcMailParser->parseMail-failed', array('error-code' => $e->getMessage()));
return false;
}
if (count($ezcMailObjectArray) > 0) {
$this->EzcMailObject = $ezcMailObjectArray[0];
// return standard email headers
$parsedMailInfosArray = $this->getHeaders();
// return x-cwl- email headers
$parsedCjwMailHeaderArray = $this->getCjwHeaders();
// merge header arrays
$parseArray = array_merge($parsedMailInfosArray, $parsedCjwMailHeaderArray);
return $parseArray;
} else {
return false;
}
}
示例7: testUidFetchByFlag
public function testUidFetchByFlag()
{
$imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
$imap->authenticate(self::$user, self::$password);
$imap->selectMailbox("inbox");
$set = $imap->fetchByFlag("undeleted");
$this->assertEquals(array(self::$ids[0], self::$ids[1], self::$ids[2], self::$ids[3]), $set->getMessageNumbers());
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
$this->assertEquals(4, count($mail));
}
示例8: testResolveCids
public function testResolveCids()
{
$parser = new ezcMailParser();
$set = new ezcMailFileSet(array(dirname(__FILE__) . '/parser/data/various/test-html-inline-images'));
$mail = $parser->parseMail($set);
$relatedParts = $mail[0]->body->getParts();
$alternativeParts = $relatedParts[0]->getParts();
$html = $alternativeParts[1]->getMainPart();
$convertArray = array('consoletools-table.png@1421450' => 'foo', 'consoletools-table.png@1421452' => 'bar');
$htmlBody = ezcMailTools::replaceContentIdRefs($html->text, $convertArray);
$expected = <<<EOFE
<html>
Here is the HTML version of your mail
with an image: <img src='foo'/>
with an image: <img src='cid:consoletools-table.png@1421451'/>
</html>
EOFE;
self::assertSame($expected, $htmlBody);
}
示例9: ezcMailImapTransportOptions
<?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('somebody@example.com', '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();
}
示例10: testContentDispositionLongHeader
public function testContentDispositionLongHeader()
{
$mail = new ezcMail();
$mail->from = new ezcMailAddress('john.doe@example.com');
$mail->subject = "яверасфăîţâşåæøåöä";
$mail->addTo(new ezcMailAddress('john.doe@example.com'));
$file = new ezcMailFile(dirname(__FILE__) . "/parts/data/fly.jpg");
$file->contentDisposition = new ezcMailContentDispositionHeader('attachment', 'яверасфăîţâşåæøåöäabcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz.jpg');
$mail->body = new ezcMailMultipartMixed(new ezcMailText('xxx'), $file);
$msg = $mail->generate();
$set = new ezcMailVariableSet($msg);
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
$parts = $mail[0]->fetchParts();
// for issue #13038, displayFileName was added to contentDisposition
$file->contentDisposition->displayFileName = 'яверасфăîţâşåæøåöäabcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz.jpg';
$this->assertEquals($file->contentDisposition, $parts[1]->contentDisposition);
}
示例11: testServerSSL
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);
}
示例12: testFetchMailUnknownCharsets
public function testFetchMailUnknownCharsets()
{
$mbox = new ezcMailMboxTransport(dirname(__FILE__) . "/data/unknown-charsets.mbox");
$set = $mbox->fetchAll();
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
$this->assertEquals("x-user-defined", $mail[0]->body->originalCharset);
$this->assertEquals("utf-8", $mail[0]->body->charset);
$this->assertEquals("Tämä on testiöö1", trim($mail[0]->body->text));
$this->assertEquals("unknown-8bit", $mail[1]->body->originalCharset);
$this->assertEquals("utf-8", $mail[1]->body->charset);
$this->assertEquals("Tämä on testiöö2", trim($mail[1]->body->text));
}
示例13: testSpaceBeforeFileName
/**
* Test for issue with extra space after "=" in header (some clients begin filename from new line and with \t prepended)
*/
public function testSpaceBeforeFileName()
{
$parser = new ezcMailParser();
$messages = array(array("Content-Disposition: attachment; filename=\r\n\t\"=?iso-8859-1?q?Lettre=20de=20motivation=20directeur=20de=20client=E8le.doc?=\"\r\n", "Lettre de motivation directeur de clientèle.doc"));
foreach ($messages as $msg) {
$set = new ezcMailVariableSet($msg[0]);
$mail = $parser->parseMail($set);
$mail = $mail[0];
// check the body
$this->assertEquals($msg[1], $mail->contentDisposition->displayFileName);
}
}
示例14: fetchNext
/**
* Return the next X messages from the mail store
*
* @param int $count number of messages to fetch (0 to fetch all)
* @return array array of ezcMail objects
*/
function fetchNext($count = 1)
{
if (isset($this->_transport->options->uidReferencing) and $this->_transport->options->uidReferencing) {
$offset = array_shift($this->_transport->listUniqueIdentifiers());
} else {
$offset = 1;
}
try {
$set = $this->_transport->fetchFromOffset($offset, $count);
if ($this->_debug) {
print "fetching {$count} messages\n";
}
} catch (ezcMailOffsetOutOfRangeException $e) {
if ($this->_debug) {
print "got to the end of the mailbox\n";
}
return array();
}
$mails = array();
$parser = new ezcMailParser();
//set property text attachment as file CRM-5408
$parser->options->parseTextAttachmentsAsFiles = true;
foreach ($set->getMessageNumbers() as $nr) {
if ($this->_debug) {
print "retrieving message {$nr}\n";
}
$single = $parser->parseMail($this->_transport->fetchByMessageNr($nr));
$mails[$nr] = $single[0];
}
return $mails;
}
示例15: testCharsetHeader
/**
* Test for issue 15456: Problems with parsing emails that have "charset = " instead of "charset="
*/
public function testCharsetHeader()
{
$parser = new ezcMailParser();
$set = new SingleFileSet('various/mail-with-broken-charset-header');
$mail = $parser->parseMail($set);
$mail = $mail[0];
$parts = $mail->fetchParts();
$this->assertEquals("wir können Ihnen mitteilen, dass einer Ihrer\n", $parts[0]->text);
}