本文整理汇总了PHP中ezcMailParser::parseMail方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailParser::parseMail方法的具体用法?PHP ezcMailParser::parseMail怎么用?PHP ezcMailParser::parseMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcMailParser
的用法示例。
在下文中一共展示了ezcMailParser::parseMail方法的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: 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;
}
}
示例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: 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;
}
示例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: markProcessed
/**
* Fetch the specified message to the local processed folder
*
* @param integer $nr number of the message to fetch
*
* @return void
*/
function markProcessed($nr)
{
if ($this->_debug) {
print "copying message {$nr} to processed folder\n";
}
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
$parser = new ezcMailParser();
$parser->parseMail($set);
$this->_leftToProcess--;
}
示例10: 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);
}
示例11: 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();
}
示例12: testGetSourceFileNames
/**
* Test modified for issue #14776: ezcMailStorageSet generates bad file names.
*/
public function testGetSourceFileNames()
{
$transport = new ezcMailImapTransport("mta1.ez.no");
$transport->authenticate("ezcomponents@mail.ez.no", "ezcomponents");
$transport->selectMailbox("Inbox");
$parser = new ezcMailParser();
$set = new ezcMailStorageSet($transport->fetchAll(), $this->tempDir);
$mail = $parser->parseMail($set);
$files = $set->getSourceFiles();
$expected = array(getmypid() . '-' . time() . '-' . 1, getmypid() . '-' . time() . '-' . 2, getmypid() . '-' . time() . '-' . 3, getmypid() . '-' . time() . '-' . 4);
for ($i = 0; $i < count($files); $i++) {
$this->assertEquals($expected[$i], basename($files[$i]));
}
}
示例13: markProcessed
/**
* Fetch the specified message to the local processed folder
*
* @param integer $nr number of the message to fetch
* @return void
*/
function markProcessed($nr)
{
if ($this->_debug) {
print "fetching message {$nr} and putting it in the processed mailbox\n";
}
$set = new ezcMailStorageSet($this->_transport->fetchByMessageNr($nr), $this->_processed);
$parser = new ezcMailParser();
$parser->parseMail($set);
$this->_transport->delete($nr);
}
示例14: 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);
}
示例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);
}