本文整理汇总了PHP中ezcMailTools类的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailTools类的具体用法?PHP ezcMailTools怎么用?PHP ezcMailTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcMailTools类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sendMail
function sendMail(ezcMail $mail)
{
$separator = "/";
$mail->appendExcludeHeaders(array('to', 'subject'));
$headers = rtrim($mail->generateHeaders());
// rtrim removes the linebreak at the end, mail doesn't want it.
if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) {
throw new ezcMailTransportException('No recipient addresses found in message header.');
}
$additionalParameters = "";
if (isset($mail->returnPath)) {
$additionalParameters = "-f{$mail->returnPath->email}";
}
$sys = eZSys::instance();
$fname = time() . '-' . rand() . '.mail';
$qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq';
$data = $headers . ezcMailTools::lineBreak();
$data .= ezcMailTools::lineBreak();
$data .= $mail->generateBody();
$data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
$success = eZFile::create($fname, $qdir, $data);
if ($success === false) {
throw new ezcMailTransportException('The email could not be sent by sendmail');
}
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:25,代码来源:eznewsletterfiletransport.php
示例2: send
public static function send($to, $subject, $body, $options = array())
{
$siteINI = eZINI::instance('site.ini');
$i18nINI = eZINI::instance('i18n.ini');
$transport = $siteINI->variable('MailSettings', 'Transport');
$charset = $i18nINI->variable('CharacterSettings', 'Charset');
$emailSender = $siteINI->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $siteINI->variable('MailSettings', 'AdminEmail');
}
if ($transport == 'SMTP') {
$mailTransport = new ezcMailSmtpTransport($siteINI->variable('MailSettings', 'TransportServer'), $siteINI->variable('MailSettings', 'TransportUser'), $siteINI->variable('MailSettings', 'TransportPassword'), $siteINI->variable('MailSettings', 'TransportPort'));
} else {
eZDebug::writeError('Only SMTP Transport supported', 'jajNewsletterSubscription::sendConfirmationMail');
throw new Exception('Only SMTP Transport supported');
}
$mail = new ezcMailComposer();
$mail->charset = $charset;
$mail->subjectCharset = $charset;
$mail->subject = $subject;
$mail->htmlText = $body;
$mail->from = ezcMailTools::parseEmailAddress($emailSender, $charset);
$mail->addTo(new ezcMailAddress($to, '', $charset));
$mail->build();
$mailTransport->send($mail);
}
开发者ID:jjohnsen,项目名称:jaj_newsletter,代码行数:26,代码来源:jajsmtptransport.php
示例3: testFoldAny76LongWord
public function testFoldAny76LongWord()
{
$reference = "Thisisalongwordthatismorethan76characterslong.Let'sseehowthisishandledbyourlittlefolder That was the first space.";
ezcMailHeaderFolder::setLimit(ezcMailHeaderFolder::SOFT_LIMIT);
$folded = ezcMailHeaderFolder::foldAny($reference);
$exploded = explode(ezcMailTools::lineBreak(), $folded);
$this->assertEquals(2, count($exploded));
$this->assertEquals(87, strlen($exploded[0]));
$this->assertEquals(26, strlen($exploded[1]));
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:10,代码来源:header_folder_test.php
示例4: generateHeaders
/**
* Override of original {@link ezcMail::generateHeaders()}.
* Allows headers customization
*
* @return string The mail headers
*/
public function generateHeaders()
{
// Workaround for encoded email addresses.
// When encoded, email addresses (at least the name param) have more characters
// By default, line length is set to 76 characters, after what a new line is created with $lineBreak.
// This operation is done during encoding via iconv (see ezcMailTools::composeEmailAddress()).
// Problem is that this operation is done a 2nd time in ezcMailPart::generateHeaders().
// Following code ensures that there is no double $lineBreak introduced
// by this process because it potentially breaks headers
$lineBreak = ezcMailTools::lineBreak();
$headers = str_replace("{$lineBreak}{$lineBreak}", $lineBreak, parent::generateHeaders());
return $headers;
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:19,代码来源:ezpmail.php
示例5: send
/**
* Sends the mail $mail using the PHP mail method.
*
* Note that a message may not arrive at the destination even though
* it was accepted for delivery.
*
* @throws ezcMailTransportException
* if the mail was not accepted for delivery by the MTA.
* @param ezcMail $mail
*/
public function send(ezcMail $mail)
{
$mail->appendExcludeHeaders(array('to', 'subject'));
$headers = rtrim($mail->generateHeaders());
// rtrim removes the linebreak at the end, mail doesn't want it.
if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) {
throw new ezcMailTransportException('No recipient addresses found in message header.');
}
$additionalParameters = "";
if (isset($mail->returnPath)) {
$additionalParameters = "-f{$mail->returnPath->email}";
}
$success = mail(ezcMailTools::composeEmailAddresses($mail->to), $mail->getHeader('Subject'), $mail->generateBody(), $headers, $additionalParameters);
if ($success === false) {
throw new ezcMailTransportException('The email could not be sent by sendmail');
}
}
开发者ID:mdb-webdev,项目名称:livehelperchat,代码行数:27,代码来源:mta_transport.php
示例6: addRelatedPart
/**
* Adds $part to the list of parts and returns the Content-ID of the part.
*
* @param ezcMailPart $part
* @return string
*/
public function addRelatedPart(ezcMailPart $part)
{
// it doesn't have a Content-ID, we must set one.
$contentId = '';
if ($part->getHeader('Content-ID') == '') {
if ($part instanceof ezcMailFile) {
$part->contentId = ezcMailTools::generateContentId(basename($part->fileName));
} else {
$part->setHeader('Content-ID', ezcMailTools::generateContentId('part'));
}
}
$contentId = trim($part->getHeader('Content-ID'), '<>');
// Set the content ID property of the ezcMailFile if one was found
if ($part instanceof ezcMailFile) {
$part->contentId = $contentId;
}
if (count($this->parts) > 0) {
$this->parts[] = $part;
} else {
$this->parts[1] = $part;
}
return $contentId;
}
开发者ID:Adeelgill,项目名称:livehelperchat,代码行数:29,代码来源:multipart_related.php
示例7: generateHtmlPart
/**
* Returns an ezcMailPart based on the HTML provided.
*
* This method adds local files/images to the mail itself using a
* {@link ezcMailMultipartRelated} object.
*
* @throws ezcBaseFileNotFoundException
* if $fileName does not exists.
* @throws ezcBaseFilePermissionProblem
* if $fileName could not be read.
* @return ezcMailPart
*/
private function generateHtmlPart()
{
$result = false;
if ($this->htmlText != '') {
$matches = array();
if ($this->options->automaticImageInclude === true) {
// recognize file:// and file:///, pick out the image, add it as a part and then..:)
preg_match_all("/<img[\\s\\*\\s]src=[\\'\"]file:\\/\\/([^ >\\'\"]+)/i", $this->htmlText, $matches);
// pictures/files can be added multiple times. We only need them once.
$matches = array_unique($matches[1]);
}
$result = new ezcMailText($this->htmlText, $this->charset, $this->encoding);
$result->subType = "html";
if (count($matches) > 0) {
$htmlPart = $result;
// wrap already existing message in an alternative part
$result = new ezcMailMultipartRelated($result);
// create a filepart and add it to the related part
// also store the ID for each part since we need those
// when we replace the originals in the HTML message.
foreach ($matches as $fileName) {
if (is_readable($fileName)) {
// @todo waiting for fix of the fileinfo extension
// $contents = file_get_contents( $fileName );
$mimeType = null;
$contentType = null;
if (ezcBaseFeatures::hasExtensionSupport('fileinfo')) {
// if fileinfo extension is available
$filePart = new ezcMailFile($fileName);
} elseif (ezcMailTools::guessContentType($fileName, $contentType, $mimeType)) {
// if fileinfo extension is not available try to get content/mime type
// from the file extension
$filePart = new ezcMailFile($fileName, $contentType, $mimeType);
} else {
// fallback in case fileinfo is not available and could not get content/mime
// type from file extension
$filePart = new ezcMailFile($fileName, "application", "octet-stream");
}
$cid = $result->addRelatedPart($filePart);
// replace the original file reference with a reference to the cid
$this->htmlText = str_replace('file://' . $fileName, 'cid:' . $cid, $this->htmlText);
} else {
if (file_exists($fileName)) {
throw new ezcBaseFilePermissionException($fileName, ezcBaseFileException::READ);
} else {
throw new ezcBaseFileNotFoundException($fileName);
}
// throw
}
}
// update mail, with replaced URLs
$htmlPart->text = $this->htmlText;
}
}
return $result;
}
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:68,代码来源:composer.php
示例8: generate
/**
* Returns the complete mail part including both the header and the body
* as a string.
*
* @return string
*/
public function generate()
{
return $this->generateHeaders() . ezcMailTools::lineBreak() . $this->generateBody();
}
开发者ID:agroknow,项目名称:mermix,代码行数:10,代码来源:part.php
示例9: testFoldingAddresses
public function testFoldingAddresses()
{
$this->mail->from = new ezcMailAddress('[email protected]');
$addresses = array('[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]');
foreach ($addresses as $address) {
$this->mail->addBcc(new ezcMailAddress($address));
}
$expected = "From: [email protected]" . ezcMailTools::lineBreak() . "To: " . ezcMailTools::lineBreak() . "Bcc: [email protected], [email protected], [email protected], [email protected], [email protected]," . ezcMailTools::lineBreak() . " [email protected], [email protected]" . ezcMailTools::lineBreak() . "Subject: " . ezcMailTools::lineBreak() . "MIME-Version: 1.0" . ezcMailTools::lineBreak() . "User-Agent: eZ Components";
$return = $this->mail->generate();
// cut away the Date and Message-ID headers as there is no way to predict what they will be
$return = join(ezcMailTools::lineBreak(), array_slice(explode(ezcMailTools::lineBreak(), $return), 0, 7));
$this->assertEquals($expected, $return);
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:13,代码来源:mail_test.php
示例10: tempnam
$newFile = tempnam($this->dir, 'mail');
copy($mailPart->fileName, $newFile);
// save location and setup ID array
$this->cids[$mailPart->contentId] = $this->webDir . '/' . basename($newFile);
}
// if we find a text part and if the sub-type is HTML (no plain text)
// we store that in the classes' htmlText property.
if ($mailPart instanceof ezcMailText) {
if ($mailPart->subType == 'html') {
$this->htmlText = $mailPart->text;
}
}
}
}
// create the collector class and set the filesystem path, and the webserver's
// path to find the attached files (images) in.
$collector = new collector();
$collector->dir = "/home/httpd/html/test/ezc";
$collector->webDir = '/test/ezc';
// We use the saveMailPart() method of the $collector object function as a
// callback in walkParts().
$context = new ezcMailPartWalkContext(array($collector, 'saveMailPart'));
// only call the callback for file and text parts.
$context->filter = array('ezcMailFile', 'ezcMailText');
// use walkParts() to iterate over all parts in the first parsed e-mail
// message.
$mail[0]->walkParts($context, $mail[0]);
// display the html text with the content IDs replaced with references to the
// file in the webroot.
echo ezcMailTools::replaceContentIdRefs($collector->htmlText, $collector->cids);
开发者ID:notion,项目名称:zeta-mail,代码行数:30,代码来源:tutorial_html_display.php
示例11: foldAny
/**
* Returns $text folded to the 998 character limit on any whitespace.
*
* The algorithm tries to minimize the number of comparisons by searching
* backwards from the maximum number of allowed characters on a line.
*
* @param string $text
* @return string
*/
public static function foldAny($text)
{
// Don't fold unless we have to.
if (strlen($text) <= self::$limit) {
return $text;
}
// go to 998'th char.
// search back to whitespace
// fold
$length = strlen($text);
$folded = "";
// find first occurence of whitespace searching backwards
$search = 0;
$previousFold = 0;
while ($search + self::$limit < $length) {
// search from the max possible length of the substring
$search += self::$limit;
while ($text[$search] != " " && $text[$search] != "\t" && $search > $previousFold) {
$search--;
}
if ($search == $previousFold) {
// continuous string of more than limit chars.
// We will just have to continue searching forwards to the next whitespace instead
// This is not confirming to standard.. but what can we do?
$search += self::$limit;
// back to where we started
while ($search < $length && $text[$search] != " " && $text[$search] != "\t") {
$search++;
}
}
// lets fold
if ($folded === "") {
$folded = substr($text, $previousFold, $search - $previousFold);
} else {
$folded .= ezcMailTools::lineBreak() . substr($text, $previousFold, $search - $previousFold);
}
$previousFold = $search;
}
// we need to append the rest if there is any
if ($search < $length) {
$folded .= ezcMailTools::lineBreak() . substr($text, $search);
}
return $folded;
}
开发者ID:agroknow,项目名称:mermix,代码行数:53,代码来源:header_folder.php
示例12: addHeadersSection
/**
* Returns the generated text for a section of the delivery-status part.
*
* @param ezcMailHeadersHolder $headers
* @return string
*/
private function addHeadersSection(ezcMailHeadersHolder $headers)
{
$result = "";
foreach ($headers->getCaseSensitiveArray() as $header => $value) {
$result .= $header . ": " . $value . ezcMailTools::lineBreak();
}
return $result;
}
开发者ID:agroknow,项目名称:mermix,代码行数:14,代码来源:delivery_status.php
示例13: testNoDoubleFold
public function testNoDoubleFold()
{
$composedAddress = ezcMailTools::composeEmailAddress(new ezcMailAddress('[email protected]', 'From name ØÆÅ test test test test with a very long name which contains norwegian characters ÆØÅæøÅ', 'utf-8'));
$this->assertSame($composedAddress, ezcMailHeaderFolder::foldAny($composedAddress));
}
开发者ID:notion,项目名称:zeta-mail,代码行数:5,代码来源:header_folder_test.php
示例14: generateHtmlPart
/**
* Returns an ezcMailPart based on the HTML provided.
*
* This method adds local files/images to the mail itself using a
* {@link ezcMailMultipartRelated} object.
*
* @throws ezcBaseFileNotFoundException
* if $fileName does not exists.
* @throws ezcBaseFilePermissionProblem
* if $fileName could not be read.
* @return ezcMailPart
*/
private function generateHtmlPart()
{
$result = false;
if ($this->htmlText != '') {
$matches = array();
if ($this->options->automaticImageInclude === true) {
/*
1.7.1 regex is buggy filename are not extract correctly
http://issues.ez.no/IssueView.php?Id=16612&
preg_match_all( '(
<img \\s+[^>]*
src\\s*=\\s*
(?:
(?# Match quoted attribute)
([\'"])file://(?P<quoted>[^>]+)\\1
(?# Match unquoted attribute, which may not contain spaces)
| file://(?P<unquoted>[^>\\s]+)
)
[^>]* >)ix', $htmlText, $matches );
* */
// CJW Newsletter regex change only find all file://ezroot/
// so it is secure
// recognize file://ezroot/ and pick out the image, add it as a part and then..:)
preg_match_all("/<img[\\s\\*\\s]src=[\\'\"]file:\\/\\/ezroot\\/([^ >\\'\"]+)/i", $this->htmlText, $matches);
// pictures/files can be added multiple times. We only need them once.
$matches = array_unique($matches[1]);
}
$result = new ezcMailText($this->htmlText, $this->charset, $this->encoding);
$result->subType = "html";
if (count($matches) > 0) {
$htmlPart = $result;
// wrap already existing message in an alternative part
$result = new ezcMailMultipartRelated($result);
// create a filepart and add it to the related part
// also store the ID for each part since we need those
// when we replace the originals in the HTML message.
foreach ($matches as $fileName) {
if (is_readable($fileName)) {
// @todo waiting for fix of the fileinfo extension
// $contents = file_get_contents( $fileName );
$mimeType = null;
$contentType = null;
if (ezcBaseFeatures::hasExtensionSupport('fileinfo')) {
// if fileinfo extension is available
$filePart = new ezcMailFile($fileName);
} elseif (ezcMailTools::guessContentType($fileName, $contentType, $mimeType)) {
// if fileinfo extension is not available try to get content/mime type
// from the file extension
$filePart = new ezcMailFile($fileName, $contentType, $mimeType);
} else {
// fallback in case fileinfo is not available and could not get content/mime
// type from file extension
$filePart = new ezcMailFile($fileName, "application", "octet-stream");
}
$cid = $result->addRelatedPart($filePart);
// replace the original file reference with a reference to the cid
$this->htmlText = str_replace('file://ezroot/' . $fileName, 'cid:' . $cid, $this->htmlText);
} else {
if (file_exists($fileName)) {
throw new ezcBaseFilePermissionException($fileName, ezcBaseFileException::READ);
} else {
throw new ezcBaseFileNotFoundException($fileName);
}
// throw
}
}
// update mail, with replaced URLs
$htmlPart->text = $this->htmlText;
}
}
return $result;
}
开发者ID:hudri,项目名称:cjw_newsletter,代码行数:88,代码来源:cjwnewslettermailcomposer.php
示例15: parseContentDisposition
/**
* Returns the a ezcMailContentDispositionHeader for the parsed $header.
*
* If $cd is provided this object will be used to fill in the blanks. This function
* will not clear out any old values in the object.
*
* @param string $header
* @param ezcMailContentDispositionHeader $cd
* @return ezcMailContentDispositionHeader
*/
public static function parseContentDisposition($header, ezcMailContentDispositionHeader $cd = null)
{
if ($cd === null) {
$cd = new ezcMailContentDispositionHeader();
}
$parsedHeader = self::parseHeader($header);
$cd->disposition = $parsedHeader[0];
if (isset($parsedHeader[1])) {
foreach ($parsedHeader[1] as $paramName => $data) {
switch ($paramName) {
case 'filename':
$cd->fileName = $data['value'];
$cd->displayFileName = trim($data['value'], '"');
if (isset($data['charset'])) {
$cd->fileNameCharSet = $data['charset'];
$cd->displayFileName = ezcMailCharsetConverter::convertToUTF8Iconv($cd->displayFileName, $cd->fileNameCharSet);
} else {
if (preg_match('@^=\\?[^?]+\\?[QqBb]\\?@', $cd->displayFileName)) {
$cd->displayFileName = ezcMailTools::mimeDecode($cd->displayFileName);
}
}
if (isset($data['language'])) {
$cd->fileNameLanguage = $data['language'];
}
break;
case 'creation-date':
$cd->creationDate = $data['value'];
break;
case 'modification-date':
$cd->modificationDate = $data['value'];
break;
case 'read-date':
$cd->readDate = $data['value'];
break;
case 'size':
$cd->size = $data['value'];
break;
default:
$cd->additionalParameters[$paramName] = $data['value'];
if (isset($data['charset'])) {
$cd->additionalParametersMetaData[$paramName]['charSet'] = $data['charset'];
}
if (isset($data['language'])) {
$cd->additionalParametersMetaData[$paramName]['language'] = $data['language'];
}
break;
}
}
}
return $cd;
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:61,代码来源:rfc2231_implementation.php
示例16: generateBody
/**
* Returns the contents of the file with the correct encoding.
*
* @return string
*/
public function generateBody()
{
return chunk_split(base64_encode(file_get_contents($this->fileName)), 76, ezcMailTools::lineBreak());
}
开发者ID:agroknow,项目名称:mermix,代码行数:9,代码来源:disk_file.php
示例17: generateBody
/**
* Returns the contents of the file with the correct encoding.
*
* @return string
*/
public function generateBody()
{
return chunk_split(base64_encode($this->contents), 76, ezcMailTools::lineBreak());
}
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:9,代码来源:virtual_file.php
示例18: generateBody
/**
* Returns the contents of the file with the correct encoding.
*
* The stream might become unusable after this if it doesn't support seek.
*
* @return string
*/
public function generateBody()
{
$contents = stream_get_contents($this->stream);
return chunk_split(base64_encode($contents), 76, ezcMailTools::lineBreak());
}
开发者ID:kidaa30,项目名称:yes,代码行数:12,代码来源:stream_file.php
示例19: testQuotedPrintableEncode
public function testQuotedPrintableEncode()
{
$reference = "Content-Type: text/plain; charset=iso-8859-1" . ezcMailTools::lineBreak() . "Content-Transfer-Encoding: quoted-printable" . ezcMailTools::lineBreak() . ezcMailTools::lineBreak() . "=E6=F8=E5=0A=F8=E6=E5";
$text = new ezcMailText("זרו\nרזו", "iso-8859-1", ezcMail::QUOTED_PRINTABLE);
$this->assertEquals($reference, $text->generate());
}
开发者ID:bmdevel,项目名称:ezc,代码行数:6,代码来源:text_part_test.php
示例20: finish
/**
* Returns an ezcMail corresponding to the parsed message.
* You can specify an alternate class using the $class parameter, if you
* extended ezcMail.
*
* @param string $class Class to instanciate instead of ezcMail.
* @return ezcMail
*/
public function finish($class = "ezcMail")
{
$mail = new $class();
$mail->setHeaders($this->headers->getCaseSensitiveArray());
ezcMailPartParser::parsePartHeaders($this->headers, $mail);
// from
if (isset($this->headers['From'])) {
$mail->from = ezcMailTools::parseEmailAddress($this->headers['From']);
}
// to
if (isset($this->headers['To'])) {
$mail->to = ezcMailTools::parseEmailAddresses($this->headers['To']);
}
// cc
if (isset($this->headers['Cc'])) {
$mail->cc = ezcMailTools::parseEmailAddresses($this->headers['Cc']);
}
// bcc
if (isset($this->headers['Bcc'])) {
$mail->bcc = ezcMailTools::parseEmailAddresses($this->headers['Bcc']);
}
// subject
if (isset($this->headers['Subject'])) {
$mail->subject = ezcMailTools::mimeDecode($this->headers['Subject']);
$mail->subjectCharset = 'utf-8';
}
// message ID
if (isset($this->headers['Message-Id'])) {
$mail->messageID = $this->headers['Message-Id'];
}
// Return-Path
if (isset($this->headers['Return-Path'])) {
$mail->returnPath = ezcMailTools::parseEmailAddress($this->headers['Return-Path']);
}
if ($this->bodyParser !== null) {
$mail->body = $this->bodyParser->finish();
}
return $mail;
}
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:47,代码来源:rfc822_parser.php
注:本文中的ezcMailTools类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论