本文整理汇总了PHP中ezcMailParser类的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailParser类的具体用法?PHP ezcMailParser怎么用?PHP ezcMailParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcMailParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:42,代码来源:Localdir.php
示例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;
}
开发者ID:teamsinger,项目名称:uk.teamsinger.civicrm.mailgun,代码行数:36,代码来源:MailgunDB.php
示例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("[email protected]", $mail[0]->from->email);
}
开发者ID:notion,项目名称:zeta-mail,代码行数:9,代码来源:transport_variable_test.php
示例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;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:28,代码来源:Maildir.php
示例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;
}
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:27,代码来源:mail.php
示例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;
}
}
开发者ID:hudri,项目名称:cjw_newsletter,代码行数:28,代码来源:cjwnewslettermailparser.php
示例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));
}
开发者ID:notion,项目名称:zeta-mail,代码行数:11,代码来源:transport_imap_uid_test.php
示例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);
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:19,代码来源:tools_test.php
示例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('[email protected]', '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();
}
开发者ID:Qafoo,项目名称:blog-examples,代码行数:18,代码来源:receive_mail.php
示例10: testContentDispositionLongHeader
public function testContentDispositionLongHeader()
{
$mail = new ezcMail();
$mail->from = new ezcMailAddress('[email protected]');
$mail->subject = "яверасфăîţâşåæøåöä";
$mail->addTo(new ezcMailAddress('[email protected]'));
$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);
}
开发者ID:bmdevel,项目名称:ezc,代码行数:18,代码来源:composer_test.php
示例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);
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:13,代码来源:transport_pop3_test.php
示例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));
}
开发者ID:notion,项目名称:zeta-mail,代码行数:13,代码来源:transport_mbox_test.php
示例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);
}
}
开发者ID:zetacomponents,项目名称:mail,代码行数:15,代码来源:parser_test.php
示例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;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:37,代码来源:MailStore.php
示例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);
}
开发者ID:bmdevel,项目名称:ezc,代码行数:12,代码来源:parser_test.php
示例16: testTagInHeadersAndBody
public function testTagInHeadersAndBody()
{
$imap = new ezcMailImapTransport(self::$server, self::$port);
$imap->authenticate(self::$user, self::$password);
$imap->createMailbox("Guybrush");
$mail = new ezcMail();
$mail->from = new ezcMailAddress('[email protected]', 'From');
$mail->addTo(new ezcMailAddress('[email protected]', 'To'));
$mail->subject = "A0000 A0001 A0002 A0003 A0004 A0005 A0006 A0007";
$mail->body = new ezcMailText("A0000\nA0001\nA0002\nA0003\nA0004\nA0005\nA0006\nA0007");
$data = $mail->generate();
$imap->append("Guybrush", $data);
$imap->append("Guybrush", $data, array('Answered'));
$imap->selectMailbox("Guybrush");
$set = $imap->fetchAll();
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
$mail = $mail[0];
$imap->selectMailbox("Inbox");
$imap->deleteMailbox("Guybrush");
$this->assertEquals('A0000 A0001 A0002 A0003 A0004 A0005 A0006 A0007', $mail->subject);
}
开发者ID:notion,项目名称:zeta-mail,代码行数:22,代码来源:transport_imap_test.php
示例17: testKmail1
public function testKmail1()
{
$parser = new ezcMailParser();
$set = new SingleFileSetMP('kmail/mail_with_attachment.mail');
$mail = $parser->parseMail($set);
}
开发者ID:notion,项目名称:zeta-mail,代码行数:6,代码来源:multipart_mixed_test.php
示例18: send
/**
* Forward a mailing reply
*
* @param int $queue_id Queue event ID of the sender
* @param string $mailing The mailing object
* @param string $bodyTxt text part of the body (ignored if $fullEmail provided)
* @param string $replyto Reply-to of the incoming message
* @param string $bodyHTML HTML part of the body (ignored if $fullEmail provided)
* @param string $fullEmail whole email to forward in one string
* @return void
* @access public
* @static
*/
public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTML = null, &$fullEmail = null)
{
if ($fullEmail) {
// parse the email and set a new destination
$parser = new ezcMailParser();
$set = new ezcMailVariableSet($fullEmail);
$parsed = array_shift($parser->parseMail($set));
$parsed->to = array(new ezcMailAddress($mailing->replyto_email));
// CRM-5567: we need to set Reply-To: so that any response
// to the forward goes to the sender of the reply
$parsed->setHeader('Reply-To', empty($replyto) ? $parsed->from->__toString() : $replyto);
// $h must be an array, so we can't use generateHeaders()'s result,
// but we have to regenerate the headers because we changed To
$parsed->generateHeaders();
$h = $parsed->headers->getCaseSensitiveArray();
$b = $parsed->generateBody();
// strip Return-Path of possible bounding brackets, CRM-4502
$h['Return-Path'] = trim($h['Return-Path'], '<>');
// FIXME: ugly hack - find the first MIME boundary in
// the body and make the boundary in the header match it
$ct =& $h['Content-Type'];
if (substr_count($ct, 'boundary=')) {
$matches = array();
preg_match('/^--(.*)$/m', $b, $matches);
$boundary = rtrim($matches[1]);
$parts = explode('boundary=', $ct);
$ct = "{$parts[0]} boundary=\"{$boundary}\"";
}
} else {
$domain =& CRM_Core_BAO_Domain::getDomain();
$emails = CRM_Core_BAO_Email::getTableName();
$eq = CRM_Mailing_Event_BAO_Queue::getTableName();
$contacts = CRM_Contact_BAO_Contact::getTableName();
$dao =& new CRM_Core_DAO();
$dao->query("SELECT {$contacts}.display_name as display_name,\n {$emails}.email as email\n FROM {$eq}\n INNER JOIN {$contacts}\n ON {$eq}.contact_id = {$contacts}.id\n INNER JOIN {$emails}\n ON {$eq}.email_id = {$emails}.id\n WHERE {$eq}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer'));
$dao->fetch();
if (empty($dao->display_name)) {
$from = $dao->email;
} else {
$from = "\"{$dao->display_name}\" <{$dao->email}>";
}
require_once 'CRM/Core/BAO/MailSettings.php';
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
// we need to wrap Mail_mime because PEAR is apparently unable to fix
// a six-year-old bug (PEAR bug #30) in Mail_mime::_encodeHeaders()
// this fixes CRM-5466
require_once 'CRM/Utils/Mail/FixedMailMIME.php';
$message =& new CRM_Utils_Mail_FixedMailMIME("\n");
$headers = array('Subject' => "Re: {$mailing->subject}", 'To' => $mailing->replyto_email, 'From' => $from, 'Reply-To' => empty($replyto) ? $dao->email : $replyto, 'Return-Path' => "do-not-reply@{$emailDomain}");
$message->setTxtBody($bodyTxt);
$message->setHTMLBody($bodyHTML);
$b =& CRM_Utils_Mail::setMimeParams($message);
$h =& $message->headers($headers);
}
$config =& CRM_Core_Config::singleton();
$mailer =& $config->getMailer();
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Core_Error', 'nullHandler'));
if (is_object($mailer)) {
$mailer->send($mailing->replyto_email, $h, $b);
CRM_Core_Error::setCallback();
}
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:75,代码来源:Reply.php
示例19: testParserCustomFileClass
/**
* Test for issue #13539: Add new mail parser option fileClass.
*/
public function testParserCustomFileClass()
{
$parser = new ezcMailParser();
$parser->options->fileClass = 'myCustomFileClass';
// to catch also the case with a custom mail class (it doesn't influence the test)
$parser->options->mailClass = 'ExtendedMail';
$set = new SingleFileSet('various/test-html-text-and-attachment');
$mail = $parser->parseMail($set);
$mail = $mail[0];
$parts = $mail->fetchParts(null, false);
$expected = array('ezcMailText', 'ezcMailText', 'myCustomFileClass', 'myCustomFileClass');
$this->assertEquals(4, count($parts));
for ($i = 0; $i < count($parts); $i++) {
$this->assertEquals($expected[$i], get_class($parts[$i]));
}
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:19,代码来源:parser_test.php
示例20: ezcMailFileSet
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
require_once "../tutorial/tutorial_autoload.php";
$set = new ezcMailFileSet(array($argv[1]));
$parser = new ezcMailParser();
$mail = $parser->parseMail($set);
echo formatMail($mail[0]);
function formatMail($mail)
{
$t = '';
$t .= "From: " . formatAddress($mail->from) . "\n";
$t .= "To: " . formatAddresses($mail->to) . "\n";
$t .= "Cc: " . formatAddresses($mail->cc) . "\n";
$t .= "Bcc: " . formatAddresses($mail->bcc) . "\n";
$t .= 'Date: ' . date(DATE_RFC822, $mail->timestamp) . "\n";
$t .= 'Subject: ' . $mail->subject . "\n";
$t .= "MessageId: " . $mail->messageId . "\n";
$t .= "\n";
$t .= formatMailPart($mail->body);
return $t;
开发者ID:notion,项目名称:zeta-mail,代码行数:31,代码来源:display-example.php
注:本文中的ezcMailParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论