update v 1.0.7.5
This commit is contained in:
@@ -22,6 +22,8 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
|
||||
/**
|
||||
* StreamFilters.
|
||||
*
|
||||
* @var Swift_StreamFilter[]
|
||||
*/
|
||||
private $_filters = array();
|
||||
|
||||
|
@@ -82,9 +82,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
|
||||
// Don't use array slice
|
||||
$end = $length + $this->_offset;
|
||||
$end = $this->_arraySize < $end
|
||||
? $this->_arraySize
|
||||
: $end;
|
||||
$end = $this->_arraySize < $end ? $this->_arraySize : $end;
|
||||
$ret = '';
|
||||
for (; $this->_offset < $end; ++$this->_offset) {
|
||||
$ret .= $this->_array[$this->_offset];
|
||||
|
@@ -139,11 +139,13 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
private function _getReadHandle()
|
||||
{
|
||||
if (!isset($this->_reader)) {
|
||||
if (!$this->_reader = fopen($this->_path, 'rb')) {
|
||||
$pointer = @fopen($this->_path, 'rb');
|
||||
if (!$pointer) {
|
||||
throw new Swift_IoException(
|
||||
'Unable to open file for reading ['.$this->_path.']'
|
||||
);
|
||||
}
|
||||
$this->_reader = $pointer;
|
||||
if ($this->_offset != 0) {
|
||||
$this->_getReadStreamSeekableStatus();
|
||||
$this->_seekReadStreamToPosition($this->_offset);
|
||||
|
@@ -82,7 +82,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe
|
||||
{
|
||||
$needed = $this->_width - $size;
|
||||
|
||||
return ($needed > -1) ? $needed : -1;
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -67,9 +67,9 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
$byte = reset($bytes);
|
||||
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -161,10 +161,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
}
|
||||
$needed = self::$length_map[$bytes[0]] - $size;
|
||||
|
||||
return ($needed > -1)
|
||||
? $needed
|
||||
: -1
|
||||
;
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -165,9 +165,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$length = ($this->_currentPos + $length > $this->_charCount)
|
||||
? $this->_charCount - $this->_currentPos
|
||||
: $length;
|
||||
$length = $this->_currentPos + $length > $this->_charCount ? $this->_charCount - $this->_currentPos : $length;
|
||||
switch ($this->_mapType) {
|
||||
case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
|
||||
$len = $length * $this->_map;
|
||||
@@ -178,10 +176,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
break;
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_INVALID:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount
|
||||
? $this->_charCount
|
||||
: $end;
|
||||
$ret = '';
|
||||
for (; $this->_currentPos < $length; ++$this->_currentPos) {
|
||||
if (isset($this->_map[$this->_currentPos])) {
|
||||
@@ -194,9 +188,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_POSITIONS:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount
|
||||
? $this->_charCount
|
||||
: $end;
|
||||
$end = $end > $this->_charCount ? $this->_charCount : $end;
|
||||
$ret = '';
|
||||
$start = 0;
|
||||
if ($this->_currentPos > 0) {
|
||||
|
@@ -311,9 +311,9 @@ class Swift_DependencyContainer
|
||||
return $reflector->newInstanceArgs(
|
||||
$this->createDependenciesFor($itemName)
|
||||
);
|
||||
} else {
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
/** Create and register a shared instance of $itemName */
|
||||
@@ -366,8 +366,8 @@ class Swift_DependencyContainer
|
||||
}
|
||||
|
||||
return $collection;
|
||||
} else {
|
||||
return $this->lookup($item);
|
||||
}
|
||||
|
||||
return $this->lookup($item);
|
||||
}
|
||||
}
|
||||
|
@@ -198,14 +198,25 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
}
|
||||
|
||||
$enc = $this->_encodeByteSequence($bytes, $size);
|
||||
if ($currentLine && $lineLen + $size >= $thisLineLength) {
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$lines[$lNo] = '';
|
||||
$currentLine = &$lines[$lNo++];
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
$lineLen += $size;
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_standardize(implode("=\r\n", $lines));
|
||||
|
@@ -39,7 +39,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
|
||||
if (!file_exists($this->_path)) {
|
||||
if (!mkdir($this->_path, 0777, true)) {
|
||||
throw new Swift_IoException('Unable to create Path ['.$this->_path.']');
|
||||
throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
}
|
||||
}
|
||||
|
||||
throw new Swift_IoException('Unable to create a file for enqueuing Message');
|
||||
throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->_path));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -289,10 +289,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
private function _getHandle($nsKey, $itemKey, $position)
|
||||
{
|
||||
if (!isset($this->_keys[$nsKey][$itemKey])) {
|
||||
$openMode = $this->hasKey($nsKey, $itemKey)
|
||||
? 'r+b'
|
||||
: 'w+b'
|
||||
;
|
||||
$openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b';
|
||||
$fp = fopen($this->_path.'/'.$nsKey.'/'.$itemKey, $openMode);
|
||||
$this->_keys[$nsKey][$itemKey] = $fp;
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ class Swift_Mailer
|
||||
* @param Swift_Mime_Message $message
|
||||
* @param array $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
* @return int The number of successful recipients. Can be 0 which indicates failure
|
||||
*/
|
||||
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
|
||||
{
|
||||
|
@@ -16,6 +16,7 @@
|
||||
class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
protected $messages = array();
|
||||
private $flushRetries = 3;
|
||||
|
||||
/**
|
||||
* Tests if this Transport mechanism has started.
|
||||
@@ -41,6 +42,14 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $retries
|
||||
*/
|
||||
public function setFlushRetries($retries)
|
||||
{
|
||||
$this->flushRetries = $retries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a message in the queue.
|
||||
*
|
||||
@@ -75,8 +84,25 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
while ($message = array_pop($this->messages)) {
|
||||
$count += $transport->send($message, $failedRecipients);
|
||||
$retries = $this->flushRetries;
|
||||
while ($retries--) {
|
||||
try {
|
||||
while ($message = array_pop($this->messages)) {
|
||||
$count += $transport->send($message, $failedRecipients);
|
||||
}
|
||||
} catch (Swift_TransportException $exception) {
|
||||
if ($retries) {
|
||||
// re-queue the message at the end of the queue to give a chance
|
||||
// to the other messages to be sent, in case the failure was due to
|
||||
// this message and not just the transport failing
|
||||
array_unshift($this->messages, $message);
|
||||
|
||||
// wait half a second before we try again
|
||||
usleep(500000);
|
||||
} else {
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
@@ -69,9 +69,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
public function setDisposition($disposition)
|
||||
{
|
||||
if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) {
|
||||
$this->getHeaders()->addParameterizedHeader(
|
||||
'Content-Disposition', $disposition
|
||||
);
|
||||
$this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -139,9 +137,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
$this->setFilename(basename($file->getPath()));
|
||||
$this->setBody($file, $contentType);
|
||||
if (!isset($contentType)) {
|
||||
$extension = strtolower(substr(
|
||||
$file->getPath(), strrpos($file->getPath(), '.') + 1
|
||||
));
|
||||
$extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));
|
||||
|
||||
if (array_key_exists($extension, $this->_mimeTypes)) {
|
||||
$this->setContentType($this->_mimeTypes[$extension]);
|
||||
|
@@ -95,15 +95,26 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||
}
|
||||
|
||||
$enc = $this->_encodeByteSequence($bytes, $size);
|
||||
if ($currentLine && $lineLen + $size >= $thisLineLength) {
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$is->write($prepend.$this->_standardize($currentLine));
|
||||
$currentLine = '';
|
||||
$prepend = "=\r\n";
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
$lineLen += $size;
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
$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));
|
||||
|
@@ -61,6 +61,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_Cont
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
$this->safeEncoder->charsetChanged($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -129,11 +129,11 @@ class Swift_Mime_Grammar
|
||||
{
|
||||
if (array_key_exists($name, self::$_grammar)) {
|
||||
return self::$_grammar[$name];
|
||||
} else {
|
||||
throw new Swift_RfcComplianceException(
|
||||
"No such grammar '".$name."' defined."
|
||||
);
|
||||
}
|
||||
|
||||
throw new Swift_RfcComplianceException(
|
||||
"No such grammar '".$name."' defined."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -98,9 +98,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
{
|
||||
$params = $this->getParameters();
|
||||
|
||||
return array_key_exists($parameter, $params)
|
||||
? $params[$parameter]
|
||||
: null;
|
||||
return array_key_exists($parameter, $params) ? $params[$parameter] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -128,9 +128,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
*/
|
||||
public function getDelSp()
|
||||
{
|
||||
return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes')
|
||||
? true
|
||||
: false;
|
||||
return 'yes' == $this->_getHeaderParameter('Content-Type', 'delsp') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +194,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
protected function _convertString($string)
|
||||
{
|
||||
$charset = strtolower($this->getCharset());
|
||||
if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) {
|
||||
if (!in_array($charset, array('utf-8', 'iso-8859-1', 'iso-8859-15', ''))) {
|
||||
// mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$string = mb_convert_encoding($string, $charset, 'utf-8');
|
||||
|
@@ -112,12 +112,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||
public function createParameterizedHeader($name, $value = null,
|
||||
$params = array())
|
||||
{
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name,
|
||||
$this->_encoder, (strtolower($name) == 'content-disposition')
|
||||
? $this->_paramEncoder
|
||||
: null,
|
||||
$this->_grammar
|
||||
);
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->_encoder, strtolower($name) == 'content-disposition' ? $this->_paramEncoder : null, $this->_grammar);
|
||||
if (isset($value)) {
|
||||
$header->setFieldBodyModel($value);
|
||||
}
|
||||
|
@@ -349,12 +349,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
{
|
||||
$lowerA = strtolower($a);
|
||||
$lowerB = strtolower($b);
|
||||
$aPos = array_key_exists($lowerA, $this->_order)
|
||||
? $this->_order[$lowerA]
|
||||
: -1;
|
||||
$bPos = array_key_exists($lowerB, $this->_order)
|
||||
? $this->_order[$lowerB]
|
||||
: -1;
|
||||
$aPos = array_key_exists($lowerA, $this->_order) ? $this->_order[$lowerA] : -1;
|
||||
$bPos = array_key_exists($lowerB, $this->_order) ? $this->_order[$lowerB] : -1;
|
||||
|
||||
if (-1 === $aPos && -1 === $bPos) {
|
||||
// just be sure to be determinist here
|
||||
return $a > $b ? -1 : 1;
|
||||
}
|
||||
|
||||
if ($aPos == -1) {
|
||||
return 1;
|
||||
@@ -362,7 +363,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ($aPos < $bPos) ? -1 : 1;
|
||||
return $aPos < $bPos ? -1 : 1;
|
||||
}
|
||||
|
||||
/** Test if the given Header is always displayed */
|
||||
|
@@ -253,7 +253,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* If $name is passed and the first parameter is a string, this name will be
|
||||
* associated with the address.
|
||||
*
|
||||
* @param string $addresses
|
||||
* @param mixed $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
|
@@ -282,11 +282,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
{
|
||||
// TODO: Try to refactor this logic
|
||||
|
||||
$compoundLevel = isset($compoundLevel)
|
||||
? $compoundLevel
|
||||
: $this->_getCompoundLevel($children)
|
||||
;
|
||||
|
||||
$compoundLevel = isset($compoundLevel) ? $compoundLevel : $this->_getCompoundLevel($children);
|
||||
$immediateChildren = array();
|
||||
$grandchildren = array();
|
||||
$newContentType = $this->_userContentType;
|
||||
@@ -311,15 +307,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($immediateChildren)) {
|
||||
if ($immediateChildren) {
|
||||
$lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel);
|
||||
|
||||
// Determine which composite media type is needed to accommodate the
|
||||
// immediate children
|
||||
foreach ($this->_compositeRanges as $mediaType => $range) {
|
||||
if ($lowestLevel > $range[0]
|
||||
&& $lowestLevel <= $range[1]) {
|
||||
if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) {
|
||||
$newContentType = $mediaType;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -349,9 +345,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return ($this->_body instanceof Swift_OutputByteStream)
|
||||
? $this->_readStream($this->_body)
|
||||
: $this->_body;
|
||||
return $this->_body instanceof Swift_OutputByteStream ? $this->_readStream($this->_body) : $this->_body;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,12 +480,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
if ($this->_cache->hasKey($this->_cacheKey, 'body')) {
|
||||
$body = $this->_cache->getString($this->_cacheKey, 'body');
|
||||
} else {
|
||||
$body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0,
|
||||
$this->getMaxLineLength()
|
||||
);
|
||||
$this->_cache->setString($this->_cacheKey, 'body', $body,
|
||||
Swift_KeyCache::MODE_WRITE
|
||||
);
|
||||
$body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength());
|
||||
$this->_cache->setString($this->_cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE);
|
||||
}
|
||||
$string .= $body;
|
||||
}
|
||||
@@ -602,9 +592,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$this->_headers->get($field)->setFieldBodyModel($model);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,9 +616,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$this->_headers->get($field)->setParameter($parameter, $value);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -716,9 +706,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
|
||||
private function _assertValidBoundary($boundary)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di',
|
||||
$boundary)) {
|
||||
if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) {
|
||||
throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.');
|
||||
}
|
||||
}
|
||||
@@ -757,18 +745,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$realLevel = $child->getNestingLevel();
|
||||
$lowercaseType = strtolower($child->getContentType());
|
||||
|
||||
if (isset($filter[$realLevel])
|
||||
&& isset($filter[$realLevel][$lowercaseType])) {
|
||||
if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) {
|
||||
return $filter[$realLevel][$lowercaseType];
|
||||
} else {
|
||||
return $realLevel;
|
||||
}
|
||||
|
||||
return $realLevel;
|
||||
}
|
||||
|
||||
private function _createChild()
|
||||
{
|
||||
return new self($this->_headers->newInstance(),
|
||||
$this->_encoder, $this->_cache, $this->_grammar);
|
||||
return new self($this->_headers->newInstance(), $this->_encoder, $this->_cache, $this->_grammar);
|
||||
}
|
||||
|
||||
private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder)
|
||||
@@ -807,17 +793,13 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
private function _childSortAlgorithm($a, $b)
|
||||
{
|
||||
$typePrefs = array();
|
||||
$types = array(
|
||||
strtolower($a->getContentType()),
|
||||
strtolower($b->getContentType()),
|
||||
);
|
||||
$types = array(strtolower($a->getContentType()), strtolower($b->getContentType()));
|
||||
|
||||
foreach ($types as $type) {
|
||||
$typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder))
|
||||
? $this->_alternativePartOrder[$type]
|
||||
: (max($this->_alternativePartOrder) + 1);
|
||||
$typePrefs[] = array_key_exists($type, $this->_alternativePartOrder) ? $this->_alternativePartOrder[$type] : max($this->_alternativePartOrder) + 1;
|
||||
}
|
||||
|
||||
return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1;
|
||||
return $typePrefs[0] >= $typePrefs[1] ? 1 : -1;
|
||||
}
|
||||
|
||||
// -- Destructor
|
||||
@@ -839,14 +821,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*/
|
||||
private function _assertValidId($id)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^'.$this->_grammar->getDefinition('id-left').'@'.
|
||||
$this->_grammar->getDefinition('id-right').'$/D',
|
||||
$id
|
||||
)) {
|
||||
throw new Swift_RfcComplianceException(
|
||||
'Invalid ID given <'.$id.'>'
|
||||
);
|
||||
if (!preg_match('/^'.$this->_grammar->getDefinition('id-left').'@'.$this->_grammar->getDefinition('id-right').'$/D', $id)) {
|
||||
throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,7 +833,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
{
|
||||
$this->_headers = clone $this->_headers;
|
||||
$this->_encoder = clone $this->_encoder;
|
||||
$this->_cacheKey = uniqid();
|
||||
$this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true));
|
||||
$children = array();
|
||||
foreach ($this->_children as $pos => $child) {
|
||||
$children[$pos] = clone $child;
|
||||
|
@@ -157,12 +157,9 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
{
|
||||
if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) {
|
||||
return $this->_replacements->getReplacementsFor($address);
|
||||
} else {
|
||||
return isset($this->_replacements[$address])
|
||||
? $this->_replacements[$address]
|
||||
: null
|
||||
;
|
||||
}
|
||||
|
||||
return isset($this->_replacements[$address]) ? $this->_replacements[$address] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -49,25 +49,13 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
|
||||
$message = $evt->getMessage();
|
||||
$failures = array_flip($evt->getFailedRecipients());
|
||||
foreach ((array) $message->getTo() as $address => $null) {
|
||||
$this->_reporter->notify(
|
||||
$message, $address, (array_key_exists($address, $failures)
|
||||
? Swift_Plugins_Reporter::RESULT_FAIL
|
||||
: Swift_Plugins_Reporter::RESULT_PASS)
|
||||
);
|
||||
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
|
||||
}
|
||||
foreach ((array) $message->getCc() as $address => $null) {
|
||||
$this->_reporter->notify(
|
||||
$message, $address, (array_key_exists($address, $failures)
|
||||
? Swift_Plugins_Reporter::RESULT_FAIL
|
||||
: Swift_Plugins_Reporter::RESULT_PASS)
|
||||
);
|
||||
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
|
||||
}
|
||||
foreach ((array) $message->getBcc() as $address => $null) {
|
||||
$this->_reporter->notify(
|
||||
$message, $address, (array_key_exists($address, $failures)
|
||||
? Swift_Plugins_Reporter::RESULT_FAIL
|
||||
: Swift_Plugins_Reporter::RESULT_PASS)
|
||||
);
|
||||
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -151,9 +151,9 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
|
||||
{
|
||||
if (isset($this->_timer)) {
|
||||
return $this->_timer->getTimestamp();
|
||||
} else {
|
||||
return time();
|
||||
}
|
||||
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -62,12 +62,12 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_ignoredHeaders = array();
|
||||
protected $_ignoredHeaders = array('return-path' => true);
|
||||
|
||||
/**
|
||||
* Signer identity.
|
||||
*
|
||||
* @var unknown_type
|
||||
* @var string
|
||||
*/
|
||||
protected $_signerIdentity;
|
||||
|
||||
@@ -143,13 +143,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
protected $_dkimHeader;
|
||||
|
||||
/**
|
||||
* Hash Handler.
|
||||
*
|
||||
* @var hash_ressource
|
||||
*/
|
||||
private $_headerHashHandler;
|
||||
|
||||
private $_bodyHashHandler;
|
||||
|
||||
private $_headerHash;
|
||||
@@ -206,7 +199,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
{
|
||||
$this->_headerHash = null;
|
||||
$this->_signedHeaders = array();
|
||||
$this->_headerHashHandler = null;
|
||||
$this->_bodyHash = null;
|
||||
$this->_bodyHashHandler = null;
|
||||
$this->_bodyCanonIgnoreStart = 2;
|
||||
@@ -381,7 +373,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$this->_showLen = true;
|
||||
$this->_maxLen = PHP_INT_MAX;
|
||||
} elseif ($len === false) {
|
||||
$this->showLen = false;
|
||||
$this->_showLen = false;
|
||||
$this->_maxLen = PHP_INT_MAX;
|
||||
} else {
|
||||
$this->_showLen = true;
|
||||
@@ -394,7 +386,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Set the signature timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time A timestamp
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
@@ -408,7 +400,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Set the signature expiration timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time A timestamp
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
@@ -588,9 +580,13 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$this->_addToHeaderHash($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is currently useless in this class but it must be
|
||||
* kept for BC reasons due to its "protected" scope. This method
|
||||
* might be overriden by custom client code.
|
||||
*/
|
||||
protected function _endOfHeaders()
|
||||
{
|
||||
//$this->_headerHash=hash_final($this->_headerHashHandler, true);
|
||||
}
|
||||
|
||||
protected function _canonicalizeBody($string)
|
||||
|
@@ -141,7 +141,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Resets internal states.
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
@@ -170,7 +170,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return int
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function write($bytes)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
@@ -203,7 +203,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -221,7 +221,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function flushBuffers()
|
||||
{
|
||||
@@ -257,7 +257,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param string $hash
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function setHashAlgorithm($hash)
|
||||
{
|
||||
@@ -271,7 +271,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param string $canon simple | nofws defaults to simple
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function setCanon($canon)
|
||||
{
|
||||
@@ -336,9 +336,9 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
{
|
||||
if ($this->_debugHeaders) {
|
||||
return array('DomainKey-Signature', 'X-DebugHash');
|
||||
} else {
|
||||
return array('DomainKey-Signature');
|
||||
}
|
||||
|
||||
return array('DomainKey-Signature');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +502,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
$this->_hashHandler = hash_init('sha1');
|
||||
break;
|
||||
}
|
||||
$this->_canonLine = '';
|
||||
$this->_bodyCanonLine = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,11 +29,12 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
|
||||
public function __construct($privateKey, $domainName, $selector)
|
||||
{
|
||||
if (extension_loaded('opendkim')) {
|
||||
$this->_peclLoaded = true;
|
||||
} else {
|
||||
if (!extension_loaded('opendkim')) {
|
||||
throw new Swift_SwiftException('php-opendkim extension not found');
|
||||
}
|
||||
|
||||
$this->_peclLoaded = true;
|
||||
|
||||
parent::__construct($privateKey, $domainName, $selector);
|
||||
}
|
||||
|
||||
@@ -61,9 +62,9 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
if (is_bool($bodyLen)) {
|
||||
$bodyLen = -1;
|
||||
}
|
||||
$hash = ($this->_hashAlgorithm == 'rsa-sha1') ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256;
|
||||
$bodyCanon = ($this->_bodyCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$headerCanon = ($this->_headerCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$hash = $this->_hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256;
|
||||
$bodyCanon = $this->_bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$headerCanon = $this->_headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen);
|
||||
// Hardcode signature Margin for now
|
||||
$this->_dkimHandler->setMargin(78);
|
||||
@@ -130,7 +131,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
/**
|
||||
* Set the signature timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
@@ -144,7 +145,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
/**
|
||||
* Set the signature expiration timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
|
@@ -41,9 +41,9 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $certificate
|
||||
* @param string $privateKey
|
||||
* @param string $encryptCertificate
|
||||
* @param string|null $signCertificate
|
||||
* @param string|null $signPrivateKey
|
||||
* @param string|null $encryptCertificate
|
||||
*/
|
||||
public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
* But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted.
|
||||
* As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients.
|
||||
*
|
||||
* @param string $signThenEncrypt
|
||||
* @param bool $signThenEncrypt
|
||||
*
|
||||
* @return Swift_Signers_SMimeSigner
|
||||
*/
|
||||
@@ -400,7 +400,6 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
}
|
||||
|
||||
$boundary = trim($contentTypeData['1'], '"');
|
||||
$boundaryLen = strlen($boundary);
|
||||
|
||||
// Skip the header and CRLF CRLF
|
||||
$fromStream->setReadPointer($headersPosEnd + 4);
|
||||
|
@@ -417,7 +417,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
foreach ($recipients as $forwardPath) {
|
||||
try {
|
||||
$this->_doRcptToCommand($forwardPath);
|
||||
$sent++;
|
||||
++$sent;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
}
|
||||
@@ -461,11 +461,17 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
/** Try to determine the hostname of the server this is run on */
|
||||
private function _lookupHostname()
|
||||
{
|
||||
if (!empty($_SERVER['SERVER_NAME'])
|
||||
&& $this->_isFqdn($_SERVER['SERVER_NAME'])) {
|
||||
if (!empty($_SERVER['SERVER_NAME']) && $this->_isFqdn($_SERVER['SERVER_NAME'])) {
|
||||
$this->_domain = $_SERVER['SERVER_NAME'];
|
||||
} elseif (!empty($_SERVER['SERVER_ADDR'])) {
|
||||
$this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
|
||||
// Set the address literal tag (See RFC 5321, section: 4.1.3)
|
||||
if (false === strpos($_SERVER['SERVER_ADDR'], ':')) {
|
||||
$prefix = ''; // IPv4 addresses are not tagged.
|
||||
} else {
|
||||
$prefix = 'IPv6:'; // Adding prefix in case of IPv6.
|
||||
}
|
||||
|
||||
$this->_domain = sprintf('[%s%s]', $prefix, $_SERVER['SERVER_ADDR']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,9 +481,9 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
// We could do a really thorough check, but there's really no point
|
||||
if (false !== $dotPos = strpos($hostname, '.')) {
|
||||
return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -373,7 +373,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
|
||||
$binary = $this->si2bin($time, 64); // create 64 bit binary string
|
||||
$timestamp = '';
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
for ($i = 0; $i < 8; ++$i) {
|
||||
$timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8)));
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
{
|
||||
$material = array(bin2hex($key[0]));
|
||||
$len = strlen($key);
|
||||
for ($i = 1; $i < $len; $i++) {
|
||||
for ($i = 1; $i < $len; ++$i) {
|
||||
list($high, $low) = str_split(bin2hex($key[$i]));
|
||||
$v = $this->castToByte(ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i));
|
||||
$material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte
|
||||
|
@@ -172,7 +172,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler
|
||||
foreach ($this->_getAuthenticatorsForAgent() as $authenticator) {
|
||||
if (in_array(strtolower($authenticator->getAuthKeyword()),
|
||||
array_map('strtolower', $this->_esmtpParams))) {
|
||||
$count++;
|
||||
++$count;
|
||||
if ($authenticator->authenticate($agent, $this->_username, $this->_password)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -42,6 +42,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
'blocking' => 1,
|
||||
'tls' => false,
|
||||
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET,
|
||||
'stream_context_options' => array(),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -139,6 +140,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
*/
|
||||
public function setEncryption($encryption)
|
||||
{
|
||||
$encryption = strtolower($encryption);
|
||||
if ('tls' == $encryption) {
|
||||
$this->_params['protocol'] = 'tcp';
|
||||
$this->_params['tls'] = true;
|
||||
@@ -160,6 +162,30 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
return $this->_params['tls'] ? 'tls' : $this->_params['protocol'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stream context options.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return Swift_Transport_EsmtpTransport
|
||||
*/
|
||||
public function setStreamOptions($options)
|
||||
{
|
||||
$this->_params['stream_context_options'] = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stream context options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStreamOptions()
|
||||
{
|
||||
return $this->_params['stream_context_options'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source IP.
|
||||
*
|
||||
@@ -197,7 +223,8 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
foreach ($handlers as $handler) {
|
||||
$assoc[$handler->getHandledKeyword()] = $handler;
|
||||
}
|
||||
uasort($assoc, array($this, '_sortHandlers'));
|
||||
|
||||
@uasort($assoc, array($this, '_sortHandlers'));
|
||||
$this->_handlers = $assoc;
|
||||
$this->_setHandlerParams();
|
||||
|
||||
|
@@ -22,9 +22,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
|
||||
*/
|
||||
private $_currentTransport;
|
||||
|
||||
/**
|
||||
* Creates a new FailoverTransport.
|
||||
*/
|
||||
// needed as __construct is called from elsewhere explicitly
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -45,6 +43,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
|
||||
{
|
||||
$maxTransports = count($this->_transports);
|
||||
$sent = 0;
|
||||
$this->_lastUsedTransport = null;
|
||||
|
||||
for ($i = 0; $i < $maxTransports
|
||||
&& $transport = $this->_getNextTransport(); ++$i) {
|
||||
@@ -53,7 +52,11 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
|
||||
$transport->start();
|
||||
}
|
||||
|
||||
return $transport->send($message, $failedRecipients);
|
||||
if ($sent = $transport->send($message, $failedRecipients)) {
|
||||
$this->_lastUsedTransport = $transport;
|
||||
|
||||
return $sent;
|
||||
}
|
||||
} catch (Swift_TransportException $e) {
|
||||
$this->_killCurrentTransport();
|
||||
}
|
||||
|
@@ -30,8 +30,13 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
protected $_transports = array();
|
||||
|
||||
/**
|
||||
* Creates a new LoadBalancedTransport.
|
||||
* The Transport used in the last successful send operation.
|
||||
*
|
||||
* @var Swift_Transport
|
||||
*/
|
||||
protected $_lastUsedTransport = null;
|
||||
|
||||
// needed as __construct is called from elsewhere explicitly
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
@@ -57,6 +62,16 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
return array_merge($this->_transports, $this->_deadTransports);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Transport used in the last successful send operation.
|
||||
*
|
||||
* @return Swift_Transport
|
||||
*/
|
||||
public function getLastUsedTransport()
|
||||
{
|
||||
return $this->_lastUsedTransport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this Transport mechanism has started.
|
||||
*
|
||||
@@ -100,6 +115,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
{
|
||||
$maxTransports = count($this->_transports);
|
||||
$sent = 0;
|
||||
$this->_lastUsedTransport = null;
|
||||
|
||||
for ($i = 0; $i < $maxTransports
|
||||
&& $transport = $this->_getNextTransport(); ++$i) {
|
||||
@@ -108,6 +124,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
$transport->start();
|
||||
}
|
||||
if ($sent = $transport->send($message, $failedRecipients)) {
|
||||
$this->_lastUsedTransport = $transport;
|
||||
break;
|
||||
}
|
||||
} catch (Swift_TransportException $e) {
|
||||
|
@@ -156,15 +156,16 @@ class Swift_Transport_MailTransport implements Swift_Transport
|
||||
if ("\r\n" != PHP_EOL) {
|
||||
// Non-windows (not using SMTP)
|
||||
$headers = str_replace("\r\n", PHP_EOL, $headers);
|
||||
$subject = str_replace("\r\n", PHP_EOL, $subject);
|
||||
$body = str_replace("\r\n", PHP_EOL, $body);
|
||||
} else {
|
||||
// Windows, using SMTP
|
||||
$headers = str_replace("\r\n.", "\r\n..", $headers);
|
||||
$subject = str_replace("\r\n.", "\r\n..", $subject);
|
||||
$body = str_replace("\r\n.", "\r\n..", $body);
|
||||
}
|
||||
|
||||
if ($this->_invoker->mail($to, $subject, $body, $headers,
|
||||
sprintf($this->_extraParams, $reversePath))) {
|
||||
if ($this->_invoker->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) {
|
||||
if ($evt) {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
|
||||
$evt->setFailedRecipients($failedRecipients);
|
||||
@@ -234,4 +235,21 @@ class Swift_Transport_MailTransport implements Swift_Transport
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return php mail extra params to use for invoker->mail.
|
||||
*
|
||||
* @param $extraParams
|
||||
* @param $reversePath
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function _formatExtraParams($extraParams, $reversePath)
|
||||
{
|
||||
if (false !== strpos($extraParams, '-f%s')) {
|
||||
$extraParams = empty($reversePath) ? str_replace('-f%s', '', $extraParams) : sprintf($extraParams, escapeshellarg($reversePath));
|
||||
}
|
||||
|
||||
return !empty($extraParams) ? $extraParams : null;
|
||||
}
|
||||
}
|
||||
|
@@ -102,6 +102,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran
|
||||
$failedRecipients = (array) $failedRecipients;
|
||||
$command = $this->getCommand();
|
||||
$buffer = $this->getBuffer();
|
||||
$count = 0;
|
||||
|
||||
if (false !== strpos($command, ' -t')) {
|
||||
if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
|
||||
|
@@ -32,8 +32,8 @@ class Swift_Transport_SimpleMailInvoker implements Swift_Transport_MailInvoker
|
||||
{
|
||||
if (!ini_get('safe_mode')) {
|
||||
return @mail($to, $subject, $body, $headers, $extraParams);
|
||||
} else {
|
||||
return @mail($to, $subject, $body, $headers);
|
||||
}
|
||||
|
||||
return @mail($to, $subject, $body, $headers);
|
||||
}
|
||||
}
|
||||
|
@@ -260,7 +260,11 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn
|
||||
if (!empty($this->_params['sourceIp'])) {
|
||||
$options['socket']['bindto'] = $this->_params['sourceIp'].':0';
|
||||
}
|
||||
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
|
||||
if (isset($this->_params['stream_context_options'])) {
|
||||
$options = array_merge($options, $this->_params['stream_context_options']);
|
||||
}
|
||||
$streamContext = stream_context_create($options);
|
||||
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
|
||||
if (false === $this->_stream) {
|
||||
throw new Swift_TransportException(
|
||||
'Connection could not be established with host '.$this->_params['host'].
|
||||
|
Reference in New Issue
Block a user