本文整理汇总了PHP中ezcMailTools::lineBreak方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcMailTools::lineBreak方法的具体用法?PHP ezcMailTools::lineBreak怎么用?PHP ezcMailTools::lineBreak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcMailTools
的用法示例。
在下文中一共展示了ezcMailTools::lineBreak方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
}
示例2: 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]));
}
示例3: 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;
}
示例4: 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();
}
示例5: testFoldingAddresses
public function testFoldingAddresses()
{
$this->mail->from = new ezcMailAddress('from@ez.no');
$addresses = array('nospam1@ez.no', 'nospam2@ez.no', 'nospam3@ez.no', 'nospam4@ez.no', 'nospam5@ez.no', 'nospam6@ez.no', 'nospam7@ez.no');
foreach ($addresses as $address) {
$this->mail->addBcc(new ezcMailAddress($address));
}
$expected = "From: from@ez.no" . ezcMailTools::lineBreak() . "To: " . ezcMailTools::lineBreak() . "Bcc: nospam1@ez.no, nospam2@ez.no, nospam3@ez.no, nospam4@ez.no, nospam5@ez.no," . ezcMailTools::lineBreak() . " nospam6@ez.no, nospam7@ez.no" . 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);
}
示例6: testEndline
public function testEndline()
{
// defaul is \n\r as specified in RFC2045
$this->assertEquals("\r\n", ezcMailTools::lineBreak());
// now let's set it and check that it works
ezcMailTools::setLineBreak("\n");
$this->assertEquals("\n", ezcMailTools::lineBreak());
}
示例7: testMailTextAndHtmlSetBase64Encoding
/**
* Test for issue #14487: Enable ezcMailComposer to specify encoding for text and html parts
*/
public function testMailTextAndHtmlSetBase64Encoding()
{
$this->mail->from = new ezcMailAddress('fh@ez.no', 'Frederik Holljen');
$this->mail->addTo(new ezcMailAddress('fh@ez.no', 'Frederik Holljen'));
$this->mail->subject = "Alternative HTML/Text message.";
$this->mail->plainText = "Plain text message. Your client should show the HTML message if it supports HTML mail.";
$this->mail->htmlText = "<html><i><b>HTML message. Your client should show this if it supports HTML.</b></i></html>";
$this->mail->encoding = ezcMail::BASE64;
$this->mail->build();
$message = $this->mail->generate();
$this->parseAndCheckParts($message, array('ezcMailText', 'ezcMailText'));
$expected = "PGh0bWw+PGk+PGI+SFRNTCBtZXNzYWdlLiBZb3VyIGNsaWVudCBzaG91bGQgc2hvdyB0aGlzIGlm" . ezcMailTools::lineBreak() . "IGl0IHN1cHBvcnRzIEhUTUwuPC9iPjwvaT48L2h0bWw+";
// test if the $expected BASE64 encoded string is found somewhere in the generated mail (at position 759 usually)
$this->assertGreaterThan(500, strpos($message, $expected));
}
示例8: appendStreamFilters
/**
* Sets the correct stream filters for the attachment.
*
* $line should contain one line of data that should be written to file.
* It is used to correctly determine the type of linebreak used in the mail.
*
* @param string $line
*/
private function appendStreamFilters($line)
{
// append the correct decoding filter
switch (strtolower($this->headers['Content-Transfer-Encoding'])) {
case 'base64':
stream_filter_append($this->fp, 'convert.base64-decode');
break;
case 'quoted-printable':
// fetch the type of linebreak
preg_match("/(\r\n|\r|\n)\$/", $line, $matches);
$lb = count($matches) > 0 ? $matches[0] : ezcMailTools::lineBreak();
$param = array('line-break-chars' => $lb);
stream_filter_append($this->fp, 'convert.quoted-printable-decode', STREAM_FILTER_WRITE, $param);
break;
case '7bit':
case '8bit':
// do nothing here, file is already just binary
break;
default:
// 7bit default
break;
}
}
示例9: 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());
}
示例10: 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());
}
示例11: 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());
}
示例12: testMockSetHeaderWithEncodingNoCharsetReturnDefault
public function testMockSetHeaderWithEncodingNoCharsetReturnDefault()
{
$part = $this->getMock('ezcMailPart', array('setHeaderCharset', 'generateBody'), array());
$part->expects($this->any())->method('setHeaderCharset')->will($this->returnValue(false));
$part->expects($this->any())->method('generateBody')->will($this->returnValue(false));
$part->setHeader("X-Related-Movie", 'James Bond - Шпион, который меня любил', 'iso-8859-5');
$this->assertEquals('James Bond - Шпион, который меня любил', $part->getHeader('X-Related-Movie'));
$expected = "X-Related-Movie: James Bond - Шпион, который меня любил" . ezcMailTools::lineBreak();
$this->assertEquals($expected, $part->generateHeaders());
}
示例13: generateBody
/**
* Returns the generated text body of this part as a string.
*
* @return string
*/
public function generateBody()
{
switch ($this->encoding) {
case ezcMail::BASE64:
// leaves a \r\n to much at the end, but since it is base64 it will decode
// properly so we just leave it
return chunk_split(base64_encode($this->text), 76, ezcMailTools::lineBreak());
break;
case ezcMail::QUOTED_PRINTABLE:
$text = preg_replace_callback('/[^\\x21-\\x3C\\x3E-\\x7E\\x09\\x20]/', function ($matches) {
return sprintf("=%02X", ord($matches[0]));
}, $this->text);
preg_match_all('/.{1,73}([^=]{0,2})?/', $text, $match);
$text = implode('=' . ezcMailTools::lineBreak(), $match[0]);
return $text;
break;
default:
return preg_replace("/\r\n|\r|\n/", ezcMailTools::lineBreak(), $this->text);
}
}
示例14: 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;
}
示例15: 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;
}