first commit
This commit is contained in:
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles Base 64 Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param int $firstLineOffset
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if (0 >= $maxLineLength || 76 < $maxLineLength) {
|
||||
$maxLineLength = 76;
|
||||
}
|
||||
|
||||
$remainder = 0;
|
||||
$base64ReadBufferRemainderBytes = null;
|
||||
|
||||
// To reduce memory usage, the output buffer is streamed to the input buffer like so:
|
||||
// Output Stream => base64encode => wrap line length => Input Stream
|
||||
// HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data)
|
||||
// otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream.
|
||||
// We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the
|
||||
// chunk of bytes read in the next iteration.
|
||||
// When the OutputStream is empty, we must flush any remainder bytes.
|
||||
while (true) {
|
||||
$readBytes = $os->read(8192);
|
||||
$atEOF = (false === $readBytes);
|
||||
|
||||
if ($atEOF) {
|
||||
$streamTheseBytes = $base64ReadBufferRemainderBytes;
|
||||
} else {
|
||||
$streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes;
|
||||
}
|
||||
$base64ReadBufferRemainderBytes = null;
|
||||
$bytesLength = \strlen($streamTheseBytes);
|
||||
|
||||
if (0 === $bytesLength) { // no data left to encode
|
||||
break;
|
||||
}
|
||||
|
||||
// if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data
|
||||
// and carry over remainder 1-2 bytes to the next loop iteration
|
||||
if (!$atEOF) {
|
||||
$excessBytes = $bytesLength % 3;
|
||||
if (0 !== $excessBytes) {
|
||||
$base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes);
|
||||
$streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes);
|
||||
}
|
||||
}
|
||||
|
||||
$encoded = base64_encode($streamTheseBytes);
|
||||
$encodedTransformed = '';
|
||||
$thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;
|
||||
|
||||
while ($thisMaxLineLength < \strlen($encoded)) {
|
||||
$encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n";
|
||||
$firstLineOffset = 0;
|
||||
$encoded = substr($encoded, $thisMaxLineLength);
|
||||
$thisMaxLineLength = $maxLineLength;
|
||||
$remainder = 0;
|
||||
}
|
||||
|
||||
if (0 < $remainingLength = \strlen($encoded)) {
|
||||
$remainder += $remainingLength;
|
||||
$encodedTransformed .= $encoded;
|
||||
$encoded = null;
|
||||
}
|
||||
|
||||
$is->write($encodedTransformed);
|
||||
|
||||
if ($atEOF) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this encoding scheme.
|
||||
* Returns the string 'base64'.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'base64';
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer using the PHP core function.
|
||||
*
|
||||
* @author Lars Strojny
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $charset;
|
||||
|
||||
/**
|
||||
* @param string|null $charset
|
||||
*/
|
||||
public function __construct($charset = null)
|
||||
{
|
||||
$this->charset = $charset ?: 'utf-8';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify this observer that the entity's charset has changed.
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode $in to $out.
|
||||
*
|
||||
* @param Swift_OutputByteStream $os to read from
|
||||
* @param Swift_InputByteStream $is to write to
|
||||
* @param int $firstLineOffset
|
||||
* @param int $maxLineLength 0 indicates the default length for this encoding
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if ('utf-8' !== $this->charset) {
|
||||
throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
|
||||
}
|
||||
|
||||
$string = '';
|
||||
|
||||
while (false !== $bytes = $os->read(8192)) {
|
||||
$string .= $bytes;
|
||||
}
|
||||
|
||||
$is->write($this->encodeString($string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MIME name of this content encoding scheme.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'quoted-printable';
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a given string to produce an encoded string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $firstLineOffset if first line needs to be shorter
|
||||
* @param int $maxLineLength 0 indicates the default length for this encoding
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if ('utf-8' !== $this->charset) {
|
||||
throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
|
||||
}
|
||||
|
||||
return $this->standardize(quoted_printable_encode($string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure CRLF is correct and HT/SPACE are in valid places.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function standardize($string)
|
||||
{
|
||||
// transform CR or LF to CRLF
|
||||
$string = preg_replace('~=0D(?!=0A)|(?<!=0D)=0A~', '=0D=0A', $string);
|
||||
// transform =0D=0A to CRLF
|
||||
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
|
||||
|
||||
switch (\ord(substr($string, -1))) {
|
||||
case 0x09:
|
||||
$string = substr_replace($string, '=09', -1);
|
||||
break;
|
||||
case 0x20:
|
||||
$string = substr_replace($string, '=20', -1);
|
||||
break;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles the case where the email body is already encoded and you just need specify the correct
|
||||
* encoding without actually changing the encoding of the body.
|
||||
*
|
||||
* @author Jan Flora <jf@penneo.com>
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_NullContentEncoder implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
/**
|
||||
* The name of this encoding scheme (probably 7bit or 8bit).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Creates a new NullContentEncoder with $name (probably 7bit or 8bit).
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a given string to produce an encoded string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
while (false !== ($bytes = $os->read(8192))) {
|
||||
$is->write($bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this encoding scheme.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
*/
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles binary/7/8-bit Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* When sending 8-bit content over SMTP, you should use
|
||||
* Swift_Transport_Esmtp_EightBitMimeHandler to enable the 8BITMIME SMTP
|
||||
* extension.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
/**
|
||||
* The name of this encoding scheme (probably 7bit or 8bit).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* True if canonical transformations should be done.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $canonical;
|
||||
|
||||
/**
|
||||
* Creates a new PlainContentEncoder with $name (probably 7bit or 8bit).
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $canonical if canonicalization transformation should be done
|
||||
*/
|
||||
public function __construct($name, $canonical = false)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->canonical = $canonical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a given string to produce an encoded string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength - 0 means no wrapping will occur
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if ($this->canonical) {
|
||||
$string = $this->canonicalize($string);
|
||||
}
|
||||
|
||||
return $this->safeWordwrap($string, $maxLineLength, "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength optional, 0 means no wrapping will occur
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
$leftOver = '';
|
||||
while (false !== $bytes = $os->read(8192)) {
|
||||
$toencode = $leftOver.$bytes;
|
||||
if ($this->canonical) {
|
||||
$toencode = $this->canonicalize($toencode);
|
||||
}
|
||||
$wrapped = $this->safeWordwrap($toencode, $maxLineLength, "\r\n");
|
||||
$lastLinePos = strrpos($wrapped, "\r\n");
|
||||
$leftOver = substr($wrapped, $lastLinePos);
|
||||
$wrapped = substr($wrapped, 0, $lastLinePos);
|
||||
|
||||
$is->write($wrapped);
|
||||
}
|
||||
if (\strlen($leftOver)) {
|
||||
$is->write($leftOver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this encoding scheme.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
*/
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A safer (but weaker) wordwrap for unicode.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $length
|
||||
* @param string $le
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function safeWordwrap($string, $length = 75, $le = "\r\n")
|
||||
{
|
||||
if (0 >= $length) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
$originalLines = explode($le, $string);
|
||||
|
||||
$lines = [];
|
||||
$lineCount = 0;
|
||||
|
||||
foreach ($originalLines as $originalLine) {
|
||||
$lines[] = '';
|
||||
$currentLine = &$lines[$lineCount++];
|
||||
|
||||
//$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine);
|
||||
$chunks = preg_split('/(?<=\s)/', $originalLine);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
if (0 != \strlen($currentLine)
|
||||
&& \strlen($currentLine.$chunk) > $length) {
|
||||
$lines[] = '';
|
||||
$currentLine = &$lines[$lineCount++];
|
||||
}
|
||||
$currentLine .= $chunk;
|
||||
}
|
||||
}
|
||||
|
||||
return implode("\r\n", $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonicalize string input (fix CRLF).
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function canonicalize($string)
|
||||
{
|
||||
return str_replace(
|
||||
["\r\n", "\r", "\n"],
|
||||
["\n", "\n", "\r\n"],
|
||||
$string
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
protected $dotEscape;
|
||||
|
||||
/**
|
||||
* Creates a new QpContentEncoder for the given CharacterStream.
|
||||
*
|
||||
* @param Swift_CharacterStream $charStream to use for reading characters
|
||||
* @param Swift_StreamFilter $filter if canonicalization should occur
|
||||
* @param bool $dotEscape if dot stuffing workaround must be enabled
|
||||
*/
|
||||
public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false)
|
||||
{
|
||||
$this->dotEscape = $dotEscape;
|
||||
parent::__construct($charStream, $filter);
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return ['charStream', 'filter', 'dotEscape'];
|
||||
}
|
||||
|
||||
protected function getSafeMapShareId()
|
||||
{
|
||||
return static::class.($this->dotEscape ? '.dotEscape' : '');
|
||||
}
|
||||
|
||||
protected function initSafeMap()
|
||||
{
|
||||
parent::initSafeMap();
|
||||
if ($this->dotEscape) {
|
||||
/* Encode . as =2e for buggy remote servers */
|
||||
unset($this->safeMap[0x2e]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* QP encoded strings have a maximum line length of 76 characters.
|
||||
* If the first line needs to be shorter, indicate the difference with
|
||||
* $firstLineOffset.
|
||||
*
|
||||
* @param Swift_OutputByteStream $os output stream
|
||||
* @param Swift_InputByteStream $is input stream
|
||||
* @param int $firstLineOffset
|
||||
* @param int $maxLineLength
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if ($maxLineLength > 76 || $maxLineLength <= 0) {
|
||||
$maxLineLength = 76;
|
||||
}
|
||||
|
||||
$thisLineLength = $maxLineLength - $firstLineOffset;
|
||||
|
||||
$this->charStream->flushContents();
|
||||
$this->charStream->importByteStream($os);
|
||||
|
||||
$currentLine = '';
|
||||
$prepend = '';
|
||||
$size = $lineLen = 0;
|
||||
|
||||
while (false !== $bytes = $this->nextSequence()) {
|
||||
// If we're filtering the input
|
||||
if (isset($this->filter)) {
|
||||
// If we can't filter because we need more bytes
|
||||
while ($this->filter->shouldBuffer($bytes)) {
|
||||
// Then collect bytes into the buffer
|
||||
if (false === $moreBytes = $this->nextSequence(1)) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($moreBytes as $b) {
|
||||
$bytes[] = $b;
|
||||
}
|
||||
}
|
||||
// And filter them
|
||||
$bytes = $this->filter->filter($bytes);
|
||||
}
|
||||
|
||||
$enc = $this->encodeByteSequence($bytes, $size);
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + (false === $i ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$is->write($prepend.$this->standardize($currentLine));
|
||||
$currentLine = '';
|
||||
$prepend = "=\r\n";
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if (false === $i) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
|
||||
}
|
||||
}
|
||||
if (\strlen($currentLine)) {
|
||||
$is->write($prepend.$this->standardize($currentLine));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this encoding scheme.
|
||||
* Returns the string 'quoted-printable'.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'quoted-printable';
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Proxy for quoted-printable content encoders.
|
||||
*
|
||||
* Switches on the best QP encoder implementation for current charset.
|
||||
*
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
/**
|
||||
* @var Swift_Mime_ContentEncoder_QpContentEncoder
|
||||
*/
|
||||
private $safeEncoder;
|
||||
|
||||
/**
|
||||
* @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
|
||||
*/
|
||||
private $nativeEncoder;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $charset;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|null $charset
|
||||
*/
|
||||
public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset)
|
||||
{
|
||||
$this->safeEncoder = $safeEncoder;
|
||||
$this->nativeEncoder = $nativeEncoder;
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->safeEncoder = clone $this->safeEncoder;
|
||||
$this->nativeEncoder = clone $this->nativeEncoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
$this->safeEncoder->charsetChanged($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
$this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'quoted-printable';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Swift_Mime_ContentEncoder
|
||||
*/
|
||||
private function getEncoder()
|
||||
{
|
||||
return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles raw Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* When sending 8-bit content over SMTP, you should use
|
||||
* Swift_Transport_Esmtp_EightBitMimeHandler to enable the 8BITMIME SMTP
|
||||
* extension.
|
||||
*
|
||||
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder
|
||||
{
|
||||
/**
|
||||
* Encode a given string to produce an encoded string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
while (false !== ($bytes = $os->read(8192))) {
|
||||
$is->write($bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this encoding scheme.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'raw';
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
*/
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user