mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°5122 - Update libs to new PHP requirements
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
use Laminas\Validator\EmailAddress as EmailAddressValidator;
|
||||
@@ -50,6 +44,8 @@ class Address implements Address\AddressInterface
|
||||
$email = $matches['email'];
|
||||
}
|
||||
$email = trim($email);
|
||||
//trim single quotes, because outlook does add single quotes to emails sometimes which is technically not valid
|
||||
$email = trim($email, '\'');
|
||||
|
||||
return new static($email, $name, $comment);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Address;
|
||||
|
||||
interface AddressInterface
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
use Countable;
|
||||
use Iterator;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
class AddressList implements Countable, Iterator
|
||||
{
|
||||
@@ -105,7 +100,7 @@ class AddressList implements Countable, Iterator
|
||||
* @param AddressList $addressList
|
||||
* @return AddressList
|
||||
*/
|
||||
public function merge(AddressList $addressList)
|
||||
public function merge(self $addressList)
|
||||
{
|
||||
foreach ($addressList as $address) {
|
||||
$this->add($address);
|
||||
@@ -163,6 +158,7 @@ class AddressList implements Countable, Iterator
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return count($this->addresses);
|
||||
@@ -175,6 +171,7 @@ class AddressList implements Countable, Iterator
|
||||
* empty.
|
||||
* @see addresses
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
return reset($this->addresses);
|
||||
@@ -185,6 +182,7 @@ class AddressList implements Countable, Iterator
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return current($this->addresses);
|
||||
@@ -195,6 +193,7 @@ class AddressList implements Countable, Iterator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return key($this->addresses);
|
||||
@@ -207,6 +206,7 @@ class AddressList implements Countable, Iterator
|
||||
* internal array pointer, or false if there are no more elements.
|
||||
* @see addresses
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
return next($this->addresses);
|
||||
@@ -217,6 +217,7 @@ class AddressList implements Countable, Iterator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
$key = key($this->addresses);
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
class ConfigProvider
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Exception;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Exception;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Exception;
|
||||
|
||||
interface ExceptionInterface
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Exception;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Exception;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Exception;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Address;
|
||||
use Laminas\Mail\AddressList;
|
||||
use Laminas\Mail\Headers;
|
||||
use TrueBV\Exception\OutOfBoundsException;
|
||||
use TrueBV\Punycode;
|
||||
use Laminas\Mail\Storage\Exception\RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Base class for headers composing address lists (to, from, cc, bcc, reply-to)
|
||||
*/
|
||||
abstract class AbstractAddressList implements HeaderInterface
|
||||
{
|
||||
private const IDNA_ERROR_MAP = [
|
||||
IDNA_ERROR_EMPTY_LABEL => 'empty label',
|
||||
IDNA_ERROR_LABEL_TOO_LONG => 'label too long',
|
||||
IDNA_ERROR_DOMAIN_NAME_TOO_LONG => 'domain name too long',
|
||||
IDNA_ERROR_LEADING_HYPHEN => 'leading hyphen',
|
||||
IDNA_ERROR_TRAILING_HYPHEN => 'trailing hyphen',
|
||||
IDNA_ERROR_HYPHEN_3_4 => 'consecutive hyphens',
|
||||
IDNA_ERROR_LEADING_COMBINING_MARK => 'leading combining mark',
|
||||
IDNA_ERROR_DISALLOWED => 'disallowed',
|
||||
IDNA_ERROR_PUNYCODE => 'invalid punycode encoding',
|
||||
IDNA_ERROR_LABEL_HAS_DOT => 'has dot',
|
||||
IDNA_ERROR_INVALID_ACE_LABEL => 'label not in ASCII encoding',
|
||||
IDNA_ERROR_BIDI => 'fails bidirectional criteria',
|
||||
IDNA_ERROR_CONTEXTJ => 'one or more characters fail CONTEXTJ rule',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var AddressList
|
||||
*/
|
||||
@@ -41,11 +51,6 @@ abstract class AbstractAddressList implements HeaderInterface
|
||||
*/
|
||||
protected static $type;
|
||||
|
||||
/**
|
||||
* @var Punycode|null
|
||||
*/
|
||||
private static $punycode;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
|
||||
@@ -114,16 +119,26 @@ abstract class AbstractAddressList implements HeaderInterface
|
||||
* @param string $domainName the UTF-8 encoded email
|
||||
* @return string
|
||||
*/
|
||||
protected function idnToAscii($domainName)
|
||||
protected function idnToAscii($domainName): string
|
||||
{
|
||||
if (null === self::$punycode) {
|
||||
self::$punycode = new Punycode();
|
||||
$ascii = idn_to_ascii($domainName, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $conversionInfo);
|
||||
if (false !== $ascii) {
|
||||
return $ascii;
|
||||
}
|
||||
try {
|
||||
return self::$punycode->encode($domainName);
|
||||
} catch (OutOfBoundsException $e) {
|
||||
return $domainName;
|
||||
|
||||
$messages = [];
|
||||
$errors = (int) $conversionInfo['errors'];
|
||||
|
||||
foreach (self::IDNA_ERROR_MAP as $flag => $message) {
|
||||
if (($flag & $errors) === $flag) {
|
||||
$messages[] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf(
|
||||
'Failed encoding domain due to errors: %s',
|
||||
implode(', ', $messages)
|
||||
));
|
||||
}
|
||||
|
||||
public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class Bcc extends AbstractAddressList
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class Cc extends AbstractAddressList
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Headers;
|
||||
@@ -18,7 +12,7 @@ class ContentDisposition implements UnstructuredInterface
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const MAX_PARAMETER_LENGTH = 76;
|
||||
public const MAX_PARAMETER_LENGTH = 76;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -95,7 +89,7 @@ class ContentDisposition implements UnstructuredInterface
|
||||
|
||||
foreach ($continuedValues as $name => $values) {
|
||||
$value = '';
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
for ($i = 0, $iMax = count($values); $i < $iMax; $i++) {
|
||||
if (! isset($values[$i])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for Content-Disposition string - incomplete continuation'.
|
||||
@@ -154,26 +148,34 @@ class ContentDisposition implements UnstructuredInterface
|
||||
}
|
||||
} else {
|
||||
// Use 'continuation' per RFC 2231
|
||||
$maxValueLength = strlen($value);
|
||||
do {
|
||||
$maxValueLength = ceil(0.6 * $maxValueLength);
|
||||
} while ($maxValueLength > self::MAX_PARAMETER_LENGTH);
|
||||
|
||||
if ($valueIsEncoded) {
|
||||
$encodedLength = strlen($value);
|
||||
$value = HeaderWrap::mimeDecodeValue($value);
|
||||
$decodedLength = strlen($value);
|
||||
$maxValueLength -= ($encodedLength - $decodedLength);
|
||||
}
|
||||
|
||||
$valueParts = str_split($value, $maxValueLength);
|
||||
$i = 0;
|
||||
foreach ($valueParts as $valuePart) {
|
||||
$attributePart = $attribute . '*' . $i++;
|
||||
if ($valueIsEncoded) {
|
||||
$valuePart = $this->getEncodedValue($valuePart);
|
||||
$fullLength = mb_strlen($value, 'UTF-8');
|
||||
while ($fullLength > 0) {
|
||||
$attributePart = $attribute . '*' . $i++ . '="';
|
||||
$attLen = mb_strlen($attributePart, 'UTF-8');
|
||||
|
||||
$subPos = 1;
|
||||
$valuePart = '';
|
||||
while ($subPos <= $fullLength) {
|
||||
$sub = mb_substr($value, 0, $subPos, 'UTF-8');
|
||||
if ($valueIsEncoded) {
|
||||
$sub = $this->getEncodedValue($sub);
|
||||
}
|
||||
if ($attLen + mb_strlen($sub, 'UTF-8') >= self::MAX_PARAMETER_LENGTH) {
|
||||
$subPos--;
|
||||
break;
|
||||
}
|
||||
$subPos++;
|
||||
$valuePart = $sub;
|
||||
}
|
||||
$result .= sprintf(';%s%s="%s"', Headers::FOLDING, $attributePart, $valuePart);
|
||||
|
||||
$value = mb_substr($value, $subPos, null, 'UTF-8');
|
||||
$fullLength = mb_strlen($value, 'UTF-8');
|
||||
$result .= ';' . Headers::FOLDING . $attributePart . $valuePart . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class ContentTransferEncoding implements HeaderInterface
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Headers;
|
||||
@@ -181,7 +175,8 @@ class ContentType implements UnstructuredInterface
|
||||
if (isset($this->parameters[$name])) {
|
||||
return $this->parameters[$name];
|
||||
}
|
||||
return;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header\Exception;
|
||||
|
||||
use Laminas\Mail\Exception\ExceptionInterface as MailException;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class From extends AbstractAddressList
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Header\Exception\InvalidArgumentException;
|
||||
use Laminas\Mime\Mime;
|
||||
|
||||
class GenericHeader implements HeaderInterface, UnstructuredInterface
|
||||
@@ -15,12 +10,12 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldName = null;
|
||||
protected $fieldName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldValue = null;
|
||||
protected $fieldValue = '';
|
||||
|
||||
/**
|
||||
* Header encoding
|
||||
@@ -73,14 +68,16 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface
|
||||
* Constructor
|
||||
*
|
||||
* @param string $fieldName Optional
|
||||
* @param string $fieldValue Optional
|
||||
* @param null|string $fieldValue Optional
|
||||
*/
|
||||
public function __construct($fieldName = null, $fieldValue = null)
|
||||
{
|
||||
if ($fieldName) {
|
||||
$this->setFieldName($fieldName);
|
||||
if (! $fieldName) {
|
||||
throw new InvalidArgumentException('Header MUST contain a field name');
|
||||
}
|
||||
|
||||
$this->setFieldName($fieldName);
|
||||
|
||||
if ($fieldValue !== null) {
|
||||
$this->setFieldValue($fieldValue);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
interface HeaderInterface
|
||||
@@ -15,14 +9,14 @@ interface HeaderInterface
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
const FORMAT_ENCODED = true;
|
||||
public const FORMAT_ENCODED = true;
|
||||
|
||||
/**
|
||||
* Return value in internal encoding which is usually UTF-8
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
const FORMAT_RAW = false;
|
||||
public const FORMAT_RAW = false;
|
||||
|
||||
/**
|
||||
* Factory to generate a header object from a string
|
||||
@@ -47,7 +41,7 @@ interface HeaderInterface
|
||||
* @param bool $format Return the value in Mime::Encoded or in Raw format
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue($format = HeaderInterface::FORMAT_RAW);
|
||||
public function getFieldValue($format = self::FORMAT_RAW);
|
||||
|
||||
/**
|
||||
* Set header encoding
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Loader\PluginClassLoader;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
@@ -50,7 +44,7 @@ final class HeaderLocator implements HeaderLocatorInterface
|
||||
public function get(string $name, ?string $default = null): ?string
|
||||
{
|
||||
$name = $this->normalizeName($name);
|
||||
return isset($this->plugins[$name]) ? $this->plugins[$name] : $default;
|
||||
return $this->plugins[$name] ?? $default;
|
||||
}
|
||||
|
||||
public function has(string $name): bool
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
final class HeaderName
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
final class HeaderValue
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Headers;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Headers;
|
||||
@@ -47,7 +41,7 @@ abstract class IdentificationField implements HeaderInterface
|
||||
$value = HeaderWrap::mimeDecodeValue($value);
|
||||
|
||||
$messageIds = array_map(
|
||||
[IdentificationField::class, "trimMessageId"],
|
||||
[self::class, "trimMessageId"],
|
||||
explode(" ", $value)
|
||||
);
|
||||
|
||||
@@ -127,7 +121,7 @@ abstract class IdentificationField implements HeaderInterface
|
||||
}
|
||||
}
|
||||
|
||||
$this->messageIds = array_map([IdentificationField::class, "trimMessageId"], $ids);
|
||||
$this->messageIds = array_map([self::class, "trimMessageId"], $ids);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class InReplyTo extends IdentificationField
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use function in_array;
|
||||
@@ -15,9 +9,9 @@ use function in_array;
|
||||
*/
|
||||
class ListParser
|
||||
{
|
||||
const CHAR_QUOTES = ['\'', '"'];
|
||||
const CHAR_DELIMS = [',', ';'];
|
||||
const CHAR_ESCAPE = '\\';
|
||||
public const CHAR_QUOTES = ['\'', '"'];
|
||||
public const CHAR_DELIMS = [',', ';'];
|
||||
public const CHAR_ESCAPE = '\\';
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class MessageId implements HeaderInterface
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class MimeVersion implements HeaderInterface
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
interface MultipleHeadersInterface extends HeaderInterface
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail\Headers;
|
||||
@@ -80,7 +74,7 @@ class Received implements HeaderInterface, MultipleHeadersInterface
|
||||
{
|
||||
$strings = [$this->toString()];
|
||||
foreach ($headers as $header) {
|
||||
if (! $header instanceof Received) {
|
||||
if (! $header instanceof self) {
|
||||
throw new Exception\RuntimeException(
|
||||
'The Received multiple header implementation can only accept an array of Received headers'
|
||||
);
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class References extends IdentificationField
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class ReplyTo extends AbstractAddressList
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mail;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
interface StructuredInterface extends HeaderInterface
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
use Laminas\Mime\Mime;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
class To extends AbstractAddressList
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Mail;
|
||||
@@ -13,10 +7,10 @@ namespace Laminas\Mail;
|
||||
use ArrayIterator;
|
||||
use Countable;
|
||||
use Iterator;
|
||||
use Laminas\Loader\PluginClassLoader;
|
||||
use Laminas\Loader\PluginClassLocator;
|
||||
use Laminas\Mail\Header\GenericHeader;
|
||||
use Laminas\Mail\Header\HeaderInterface;
|
||||
use ReturnTypeWillChange;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
@@ -27,10 +21,10 @@ use Traversable;
|
||||
class Headers implements Countable, Iterator
|
||||
{
|
||||
/** @var string End of Line for fields */
|
||||
const EOL = "\r\n";
|
||||
public const EOL = "\r\n";
|
||||
|
||||
/** @var string Start of Line when folding */
|
||||
const FOLDING = "\r\n ";
|
||||
public const FOLDING = "\r\n ";
|
||||
|
||||
/**
|
||||
* @var null|Header\HeaderLocatorInterface
|
||||
@@ -84,14 +78,17 @@ class Headers implements Countable, Iterator
|
||||
for ($i = 0; $i < $total; $i += 1) {
|
||||
$line = $lines[$i];
|
||||
|
||||
// Empty line indicates end of headers
|
||||
// EXCEPT if there are more lines, in which case, there's a possible error condition
|
||||
if (preg_match('/^\s*$/', $line)) {
|
||||
if ($line === "") {
|
||||
// Empty line indicates end of headers
|
||||
// EXCEPT if there are more lines, in which case, there's a possible error condition
|
||||
$emptyLine += 1;
|
||||
if ($emptyLine > 2) {
|
||||
throw new Exception\RuntimeException('Malformed header detected');
|
||||
}
|
||||
continue;
|
||||
} elseif (preg_match('/^\s*$/', $line)) {
|
||||
// skip empty continuation line
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($emptyLine > 1) {
|
||||
@@ -377,7 +374,7 @@ class Headers implements Countable, Iterator
|
||||
$key = $this->normalizeFieldName($name);
|
||||
$results = [];
|
||||
|
||||
foreach (array_keys($this->headersKeys, $key) as $index) {
|
||||
foreach (array_keys($this->headersKeys, $key, true) as $index) {
|
||||
if ($this->headers[$index] instanceof Header\GenericHeader) {
|
||||
$results[] = $this->lazyLoadHeader($index);
|
||||
} else {
|
||||
@@ -391,10 +388,8 @@ class Headers implements Countable, Iterator
|
||||
case 1:
|
||||
if ($results[0] instanceof Header\MultipleHeadersInterface) {
|
||||
return new ArrayIterator($results);
|
||||
} else {
|
||||
return $results[0];
|
||||
}
|
||||
//fall-trough
|
||||
return $results[0];
|
||||
default:
|
||||
return new ArrayIterator($results);
|
||||
}
|
||||
@@ -409,13 +404,14 @@ class Headers implements Countable, Iterator
|
||||
public function has($name)
|
||||
{
|
||||
$name = $this->normalizeFieldName($name);
|
||||
return in_array($name, $this->headersKeys);
|
||||
return in_array($name, $this->headersKeys, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Advance the pointer for this object as an iterator
|
||||
*
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
next($this->headers);
|
||||
@@ -426,6 +422,7 @@ class Headers implements Countable, Iterator
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return key($this->headers);
|
||||
@@ -436,6 +433,7 @@ class Headers implements Countable, Iterator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
return (current($this->headers) !== false);
|
||||
@@ -445,6 +443,7 @@ class Headers implements Countable, Iterator
|
||||
* Reset the internal pointer for this object as an iterator
|
||||
*
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
reset($this->headers);
|
||||
@@ -455,6 +454,7 @@ class Headers implements Countable, Iterator
|
||||
*
|
||||
* @return Header\HeaderInterface
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
$current = current($this->headers);
|
||||
@@ -470,6 +470,7 @@ class Headers implements Countable, Iterator
|
||||
*
|
||||
* @return int count of currently known headers
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return count($this->headers);
|
||||
@@ -541,7 +542,7 @@ class Headers implements Countable, Iterator
|
||||
*/
|
||||
public function loadHeader($headerLine)
|
||||
{
|
||||
list($name, ) = Header\GenericHeader::splitHeaderLine($headerLine);
|
||||
list($name) = Header\GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
/** @var HeaderInterface $class */
|
||||
$class = $this->resolveHeaderClass($name);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
use Laminas\Mail\Header\Bcc;
|
||||
use Laminas\Mail\Header\Cc;
|
||||
use Laminas\Mail\Header\ContentType;
|
||||
use Laminas\Mail\Header\From;
|
||||
use Laminas\Mail\Header\MimeVersion;
|
||||
use Laminas\Mail\Header\ReplyTo;
|
||||
use Laminas\Mail\Header\Sender;
|
||||
use Laminas\Mail\Header\To;
|
||||
use Laminas\Mime;
|
||||
use Traversable;
|
||||
|
||||
@@ -139,7 +139,7 @@ class Message
|
||||
*/
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->getAddressListFromHeader('from', __NAMESPACE__ . '\Header\From');
|
||||
return $this->getAddressListFromHeader('from', From::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +178,7 @@ class Message
|
||||
*/
|
||||
public function getTo()
|
||||
{
|
||||
return $this->getAddressListFromHeader('to', __NAMESPACE__ . '\Header\To');
|
||||
return $this->getAddressListFromHeader('to', To::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@ class Message
|
||||
*/
|
||||
public function getCc()
|
||||
{
|
||||
return $this->getAddressListFromHeader('cc', __NAMESPACE__ . '\Header\Cc');
|
||||
return $this->getAddressListFromHeader('cc', Cc::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +252,7 @@ class Message
|
||||
*/
|
||||
public function getBcc()
|
||||
{
|
||||
return $this->getAddressListFromHeader('bcc', __NAMESPACE__ . '\Header\Bcc');
|
||||
return $this->getAddressListFromHeader('bcc', Bcc::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,7 +291,7 @@ class Message
|
||||
*/
|
||||
public function getReplyTo()
|
||||
{
|
||||
return $this->getAddressListFromHeader('reply-to', __NAMESPACE__ . '\Header\ReplyTo');
|
||||
return $this->getAddressListFromHeader('reply-to', ReplyTo::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +304,7 @@ class Message
|
||||
public function setSender($emailOrAddress, $name = null)
|
||||
{
|
||||
/** @var Sender $header */
|
||||
$header = $this->getHeaderByName('sender', __NAMESPACE__ . '\Header\Sender');
|
||||
$header = $this->getHeaderByName('sender', Sender::class);
|
||||
$header->setAddress($emailOrAddress, $name);
|
||||
return $this;
|
||||
}
|
||||
@@ -322,7 +322,7 @@ class Message
|
||||
}
|
||||
|
||||
/** @var Sender $header */
|
||||
$header = $this->getHeaderByName('sender', __NAMESPACE__ . '\Header\Sender');
|
||||
$header = $this->getHeaderByName('sender', Sender::class);
|
||||
return $header->getAddress();
|
||||
}
|
||||
|
||||
@@ -398,14 +398,14 @@ class Message
|
||||
|
||||
// Get headers, and set Mime-Version header
|
||||
$headers = $this->getHeaders();
|
||||
$this->getHeaderByName('mime-version', __NAMESPACE__ . '\Header\MimeVersion');
|
||||
$this->getHeaderByName('mime-version', MimeVersion::class);
|
||||
|
||||
// Multipart content headers
|
||||
if ($this->body->isMultiPart()) {
|
||||
$mime = $this->body->getMime();
|
||||
|
||||
/** @var ContentType $header */
|
||||
$header = $this->getHeaderByName('content-type', __NAMESPACE__ . '\Header\ContentType');
|
||||
$header = $this->getHeaderByName('content-type', ContentType::class);
|
||||
$header->setType('multipart/mixed');
|
||||
$header->addParameter('boundary', $mime->boundary());
|
||||
return $this;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
use Traversable;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
class Module
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
use Laminas\Validator;
|
||||
@@ -21,12 +15,12 @@ abstract class AbstractProtocol
|
||||
/**
|
||||
* Mail default EOL string
|
||||
*/
|
||||
const EOL = "\r\n";
|
||||
public const EOL = "\r\n";
|
||||
|
||||
/**
|
||||
* Default timeout in seconds for initiating session
|
||||
*/
|
||||
const TIMEOUT_CONNECTION = 30;
|
||||
public const TIMEOUT_CONNECTION = 30;
|
||||
|
||||
/**
|
||||
* Maximum of the transaction log
|
||||
@@ -172,15 +166,14 @@ abstract class AbstractProtocol
|
||||
$this->log = [];
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Add the transaction log
|
||||
*
|
||||
* @param string $value new transaction
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _addLog($value)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ($this->maximumLog >= 0 && count($this->log) >= $this->maximumLog) {
|
||||
array_shift($this->log);
|
||||
}
|
||||
@@ -188,7 +181,6 @@ abstract class AbstractProtocol
|
||||
$this->log[] = $value;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Connect to the server using the supplied transport and target
|
||||
*
|
||||
@@ -200,9 +192,9 @@ abstract class AbstractProtocol
|
||||
* @throws Exception\RuntimeException
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _connect($remote)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$errorNum = 0;
|
||||
$errorStr = '';
|
||||
|
||||
@@ -230,20 +222,18 @@ abstract class AbstractProtocol
|
||||
return $result;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Disconnect from remote host and free resource
|
||||
*
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _disconnect()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (is_resource($this->socket)) {
|
||||
fclose($this->socket);
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Send the given request followed by a LINEEND to the server.
|
||||
*
|
||||
@@ -251,9 +241,9 @@ abstract class AbstractProtocol
|
||||
* @throws Exception\RuntimeException
|
||||
* @return int|bool Number of bytes written to remote host
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _send($request)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! is_resource($this->socket)) {
|
||||
throw new Exception\RuntimeException('No connection has been established to ' . $this->host);
|
||||
}
|
||||
@@ -272,7 +262,6 @@ abstract class AbstractProtocol
|
||||
return $result;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Get a line from the stream.
|
||||
*
|
||||
@@ -280,9 +269,9 @@ abstract class AbstractProtocol
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _receive($timeout = null)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! is_resource($this->socket)) {
|
||||
throw new Exception\RuntimeException('No connection has been established to ' . $this->host);
|
||||
}
|
||||
@@ -301,7 +290,7 @@ abstract class AbstractProtocol
|
||||
// Check meta data to ensure connection is still valid
|
||||
$info = stream_get_meta_data($this->socket);
|
||||
|
||||
if (! empty($info['timed_out'])) {
|
||||
if ($info['timed_out']) {
|
||||
throw new Exception\RuntimeException($this->host . ' has timed out');
|
||||
}
|
||||
|
||||
@@ -312,7 +301,6 @@ abstract class AbstractProtocol
|
||||
return $response;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Parse server response for successful codes
|
||||
*
|
||||
@@ -324,9 +312,9 @@ abstract class AbstractProtocol
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string Last line of response string
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _expect($code, $timeout = null)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->response = [];
|
||||
$errMsg = '';
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol\Exception;
|
||||
|
||||
use Laminas\Mail\Exception\ExceptionInterface as MailException;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
class Imap
|
||||
@@ -15,7 +9,7 @@ class Imap
|
||||
/**
|
||||
* Default timeout in seconds for initiating session
|
||||
*/
|
||||
const TIMEOUT_CONNECTION = 30;
|
||||
public const TIMEOUT_CONNECTION = 30;
|
||||
|
||||
/**
|
||||
* @var null|resource
|
||||
@@ -290,13 +284,13 @@ class Imap
|
||||
// last to chars are still needed for response code
|
||||
$tokens = [substr($tokens, 0, 2)];
|
||||
}
|
||||
|
||||
// last line has response code
|
||||
if ($tokens[0] == 'OK') {
|
||||
return $lines ? $lines : true;
|
||||
} elseif ($tokens[0] == 'NO') {
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,10 +358,11 @@ class Imap
|
||||
if (func_num_args() < 2) {
|
||||
if (strpos($string, "\n") !== false) {
|
||||
return ['{' . strlen($string) . '}', $string];
|
||||
} else {
|
||||
return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
|
||||
}
|
||||
|
||||
return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach (func_get_args() as $string) {
|
||||
$result[] = $this->escapeString($string);
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
use Laminas\Stdlib\ErrorHandler;
|
||||
@@ -17,7 +11,7 @@ class Pop3
|
||||
/**
|
||||
* Default timeout in seconds for initiating session
|
||||
*/
|
||||
const TIMEOUT_CONNECTION = 30;
|
||||
public const TIMEOUT_CONNECTION = 30;
|
||||
|
||||
/**
|
||||
* saves if server supports top
|
||||
@@ -127,7 +121,7 @@ class Pop3
|
||||
public function sendRequest($request)
|
||||
{
|
||||
ErrorHandler::start();
|
||||
$result = fputs($this->socket, $request . "\r\n");
|
||||
$result = fwrite($this->socket, $request . "\r\n");
|
||||
$error = ErrorHandler::stop();
|
||||
if (! $result) {
|
||||
throw new Exception\RuntimeException('send failed - connection closed?', 0, $error);
|
||||
@@ -171,7 +165,7 @@ class Pop3
|
||||
}
|
||||
$message .= $line;
|
||||
$line = fgets($this->socket);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return $message;
|
||||
@@ -209,7 +203,6 @@ class Pop3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get capabilities from POP3 server
|
||||
*
|
||||
@@ -221,7 +214,6 @@ class Pop3
|
||||
return explode("\n", $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Login to POP3 server. Can use APOP
|
||||
*
|
||||
@@ -244,7 +236,6 @@ class Pop3
|
||||
$this->request("PASS $password");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make STAT call for message count and size sum
|
||||
*
|
||||
@@ -260,7 +251,6 @@ class Pop3
|
||||
list($messages, $octets) = explode(' ', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make LIST call for size of message(s)
|
||||
*
|
||||
@@ -288,7 +278,6 @@ class Pop3
|
||||
return $messages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make UIDL call for getting a uniqueid
|
||||
*
|
||||
@@ -319,7 +308,6 @@ class Pop3
|
||||
return $messages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make TOP call for getting headers and maybe some body lines
|
||||
* This method also sets hasTop - before it it's not known if top is supported
|
||||
@@ -339,9 +327,9 @@ class Pop3
|
||||
if ($this->hasTop === false) {
|
||||
if ($fallback) {
|
||||
return $this->retrieve($msgno);
|
||||
} else {
|
||||
throw new Exception\RuntimeException('top not supported and no fallback wanted');
|
||||
}
|
||||
|
||||
throw new Exception\RuntimeException('top not supported and no fallback wanted');
|
||||
}
|
||||
$this->hasTop = true;
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
use Laminas\Stdlib\ErrorHandler;
|
||||
@@ -21,7 +15,6 @@ trait ProtocolTrait
|
||||
*/
|
||||
protected $novalidatecert;
|
||||
|
||||
|
||||
public function getCryptoMethod(): int
|
||||
{
|
||||
// Allow the best TLS version(s) we can
|
||||
@@ -72,7 +65,7 @@ trait ProtocolTrait
|
||||
'ssl' => [
|
||||
'verify_peer_name' => false,
|
||||
'verify_peer' => false,
|
||||
]
|
||||
],
|
||||
]
|
||||
: [];
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
use Generator;
|
||||
use Laminas\Mail\Headers;
|
||||
|
||||
/**
|
||||
* SMTP implementation of Laminas\Mail\Protocol\AbstractProtocol
|
||||
*
|
||||
@@ -18,6 +15,13 @@ class Smtp extends AbstractProtocol
|
||||
{
|
||||
use ProtocolTrait;
|
||||
|
||||
/**
|
||||
* RFC 5322 section-2.2.3 specifies maximum of 998 bytes per line.
|
||||
* This may not be exceeded.
|
||||
* @see https://tools.ietf.org/html/rfc5322#section-2.2.3
|
||||
*/
|
||||
public const SMTP_LINE_LIMIT = 998;
|
||||
|
||||
/**
|
||||
* The transport method for the socket
|
||||
*
|
||||
@@ -170,6 +174,61 @@ class Smtp extends AbstractProtocol
|
||||
return $this->useCompleteQuit = (bool) $useCompleteQuit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read $data as lines terminated by "\n"
|
||||
*
|
||||
* @param string $data
|
||||
* @param int $chunkSize
|
||||
* @return Generator|string[]
|
||||
* @author Elan Ruusamäe <glen@pld-linux.org>
|
||||
*/
|
||||
private static function chunkedReader(string $data, int $chunkSize = 4096): Generator
|
||||
{
|
||||
if (($fp = fopen("php://temp", "r+")) === false) {
|
||||
throw new Exception\RuntimeException('cannot fopen');
|
||||
}
|
||||
if (fwrite($fp, $data) === false) {
|
||||
throw new Exception\RuntimeException('cannot fwrite');
|
||||
}
|
||||
rewind($fp);
|
||||
|
||||
$line = null;
|
||||
while (($buffer = fgets($fp, $chunkSize)) !== false) {
|
||||
$line .= $buffer;
|
||||
|
||||
// This is optimization to avoid calling length() in a loop.
|
||||
// We need to match a condition that is when:
|
||||
// 1. maximum was read from fgets, which is $chunkSize-1
|
||||
// 2. last byte of the buffer is not \n
|
||||
//
|
||||
// to access last byte of buffer, we can do
|
||||
// - $buffer[strlen($buffer)-1]
|
||||
// and when maximum is read from fgets, then:
|
||||
// - strlen($buffer) === $chunkSize-1
|
||||
// - strlen($buffer)-1 === $chunkSize-2
|
||||
// which means this is also true:
|
||||
// - $buffer[strlen($buffer)-1] === $buffer[$chunkSize-2]
|
||||
//
|
||||
// the null coalesce works, as string offset can never be null
|
||||
$lastByte = $buffer[$chunkSize - 2] ?? null;
|
||||
|
||||
// partial read, continue loop to read again to complete the line
|
||||
// compare \n first as that's usually false
|
||||
if ($lastByte !== "\n" && $lastByte !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield $line;
|
||||
$line = null;
|
||||
}
|
||||
|
||||
if ($line !== null) {
|
||||
yield $line;
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not send QUIT command
|
||||
*
|
||||
@@ -260,7 +319,6 @@ class Smtp extends AbstractProtocol
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Issues MAIL command
|
||||
*
|
||||
@@ -282,7 +340,6 @@ class Smtp extends AbstractProtocol
|
||||
$this->data = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Issues RCPT command
|
||||
*
|
||||
@@ -301,7 +358,6 @@ class Smtp extends AbstractProtocol
|
||||
$this->rcpt = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Issues DATA command
|
||||
*
|
||||
@@ -318,32 +374,31 @@ class Smtp extends AbstractProtocol
|
||||
$this->_send('DATA');
|
||||
$this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2
|
||||
|
||||
if (($fp = fopen("php://temp", "r+")) === false) {
|
||||
throw new Exception\RuntimeException('cannot fopen');
|
||||
}
|
||||
if (fwrite($fp, $data) === false) {
|
||||
throw new Exception\RuntimeException('cannot fwrite');
|
||||
}
|
||||
unset($data);
|
||||
rewind($fp);
|
||||
|
||||
// max line length is 998 char + \r\n = 1000
|
||||
while (($line = stream_get_line($fp, 1000, "\n")) !== false) {
|
||||
$line = rtrim($line, "\r");
|
||||
$reader = self::chunkedReader($data);
|
||||
foreach ($reader as $line) {
|
||||
$line = rtrim($line, "\r\n");
|
||||
if (isset($line[0]) && $line[0] === '.') {
|
||||
// Escape lines prefixed with a '.'
|
||||
$line = '.' . $line;
|
||||
}
|
||||
|
||||
if (strlen($line) > self::SMTP_LINE_LIMIT) {
|
||||
// Long lines are "folded" by inserting "<CR><LF><SPACE>"
|
||||
// https://tools.ietf.org/html/rfc5322#section-2.2.3
|
||||
// Add "-1" to stay within limits,
|
||||
// because Headers::FOLDING includes a byte for space character after \r\n
|
||||
$chunks = chunk_split($line, self::SMTP_LINE_LIMIT - 1, Headers::FOLDING);
|
||||
$line = substr($chunks, 0, -strlen(Headers::FOLDING));
|
||||
}
|
||||
|
||||
$this->_send($line);
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$this->_send('.');
|
||||
$this->_expect(250, 600); // Timeout set for 10 minutes as per RFC 2821 4.5.3.2
|
||||
$this->data = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Issues the RSET command end validates answer
|
||||
*
|
||||
@@ -427,13 +482,12 @@ class Smtp extends AbstractProtocol
|
||||
$this->_disconnect();
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Disconnect from remote host and free resource
|
||||
*/
|
||||
// @codingStandardsIgnoreLine PSR2.Methods.MethodDeclaration.Underscore
|
||||
protected function _disconnect()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
// Make sure the session gets closed
|
||||
$this->quit();
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol\Smtp\Auth;
|
||||
|
||||
use Laminas\Crypt\Hmac;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol\Smtp\Auth;
|
||||
|
||||
use Laminas\Mail\Protocol\Smtp;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol\Smtp\Auth;
|
||||
|
||||
use Laminas\Mail\Protocol\Smtp;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
use Laminas\ServiceManager\AbstractPluginManager;
|
||||
@@ -79,15 +73,15 @@ class SmtpPluginManager extends AbstractPluginManager
|
||||
/**
|
||||
* Validate a retrieved plugin instance (v3).
|
||||
*
|
||||
* @param object $plugin
|
||||
* @param object|array $instance
|
||||
* @throws InvalidServiceException
|
||||
*/
|
||||
public function validate($plugin)
|
||||
public function validate($instance)
|
||||
{
|
||||
if (! $plugin instanceof $this->instanceOf) {
|
||||
if (! $instance instanceof $this->instanceOf) {
|
||||
throw new InvalidServiceException(sprintf(
|
||||
'Plugin of type %s is invalid; must extend %s',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
(is_object($instance) ? get_class($instance) : gettype($instance)),
|
||||
$this->instanceOf
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Protocol;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail;
|
||||
|
||||
class Storage
|
||||
{
|
||||
// maildir and IMAP flags, using IMAP names, where possible to be able to distinguish between IMAP
|
||||
// system flags and other flags
|
||||
const FLAG_PASSED = 'Passed';
|
||||
const FLAG_SEEN = '\Seen';
|
||||
const FLAG_UNSEEN = '\Unseen';
|
||||
const FLAG_ANSWERED = '\Answered';
|
||||
const FLAG_FLAGGED = '\Flagged';
|
||||
const FLAG_DELETED = '\Deleted';
|
||||
const FLAG_DRAFT = '\Draft';
|
||||
const FLAG_RECENT = '\Recent';
|
||||
public const FLAG_PASSED = 'Passed';
|
||||
public const FLAG_SEEN = '\Seen';
|
||||
public const FLAG_UNSEEN = '\Unseen';
|
||||
public const FLAG_ANSWERED = '\Answered';
|
||||
public const FLAG_FLAGGED = '\Flagged';
|
||||
public const FLAG_DELETED = '\Deleted';
|
||||
public const FLAG_DRAFT = '\Draft';
|
||||
public const FLAG_RECENT = '\Recent';
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use ReturnTypeWillChange;
|
||||
use SeekableIterator;
|
||||
|
||||
abstract class AbstractStorage implements
|
||||
@@ -188,6 +183,7 @@ abstract class AbstractStorage implements
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return $this->countMessages();
|
||||
@@ -199,6 +195,7 @@ abstract class AbstractStorage implements
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetExists($id)
|
||||
{
|
||||
try {
|
||||
@@ -217,6 +214,7 @@ abstract class AbstractStorage implements
|
||||
* @param int $id
|
||||
* @return \Laminas\Mail\Storage\Message message object
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet($id)
|
||||
{
|
||||
return $this->getMessage($id);
|
||||
@@ -229,6 +227,7 @@ abstract class AbstractStorage implements
|
||||
* @param mixed $value
|
||||
* @throws Exception\RuntimeException
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetSet($id, $value)
|
||||
{
|
||||
throw new Exception\RuntimeException('cannot write mail messages via array access');
|
||||
@@ -240,6 +239,7 @@ abstract class AbstractStorage implements
|
||||
* @param int $id
|
||||
* @return bool success
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetUnset($id)
|
||||
{
|
||||
return $this->removeMessage($id);
|
||||
@@ -252,6 +252,7 @@ abstract class AbstractStorage implements
|
||||
* the interfaces and your scripts take long you should use reset()
|
||||
* from time to time.
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
$this->iterationMax = $this->countMessages();
|
||||
@@ -263,6 +264,7 @@ abstract class AbstractStorage implements
|
||||
*
|
||||
* @return Message current message
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->getMessage($this->iterationPos);
|
||||
@@ -273,6 +275,7 @@ abstract class AbstractStorage implements
|
||||
*
|
||||
* @return int id of current position
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return $this->iterationPos;
|
||||
@@ -281,6 +284,7 @@ abstract class AbstractStorage implements
|
||||
/**
|
||||
* Iterator::next()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
++$this->iterationPos;
|
||||
@@ -291,6 +295,7 @@ abstract class AbstractStorage implements
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
if ($this->iterationMax === null) {
|
||||
@@ -305,6 +310,7 @@ abstract class AbstractStorage implements
|
||||
* @param int $pos
|
||||
* @throws Exception\OutOfBoundsException
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function seek($pos)
|
||||
{
|
||||
if ($this->iterationMax === null) {
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Exception;
|
||||
|
||||
use Laminas\Mail\Exception\ExceptionInterface as MailException;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use RecursiveIterator;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
class Folder implements RecursiveIterator
|
||||
{
|
||||
@@ -58,10 +53,11 @@ class Folder implements RecursiveIterator
|
||||
*
|
||||
* @return bool current element has children
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function hasChildren()
|
||||
{
|
||||
$current = $this->current();
|
||||
return $current && $current instanceof Folder && ! $current->isLeaf();
|
||||
return $current && $current instanceof self && ! $current->isLeaf();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +65,7 @@ class Folder implements RecursiveIterator
|
||||
*
|
||||
* @return \Laminas\Mail\Storage\Folder same as self::current()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->current();
|
||||
@@ -79,6 +76,7 @@ class Folder implements RecursiveIterator
|
||||
*
|
||||
* @return bool check if there's a current element
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
return key($this->folders) !== null;
|
||||
@@ -87,6 +85,7 @@ class Folder implements RecursiveIterator
|
||||
/**
|
||||
* implements Iterator::next()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
next($this->folders);
|
||||
@@ -97,6 +96,7 @@ class Folder implements RecursiveIterator
|
||||
*
|
||||
* @return string key/local name of current element
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return key($this->folders);
|
||||
@@ -107,6 +107,7 @@ class Folder implements RecursiveIterator
|
||||
*
|
||||
* @return \Laminas\Mail\Storage\Folder current folder
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return current($this->folders);
|
||||
@@ -115,6 +116,7 @@ class Folder implements RecursiveIterator
|
||||
/**
|
||||
* implements Iterator::rewind()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
reset($this->folders);
|
||||
@@ -142,7 +144,7 @@ class Folder implements RecursiveIterator
|
||||
* @param string $name local name of subfolder
|
||||
* @param \Laminas\Mail\Storage\Folder $folder instance for new subfolder
|
||||
*/
|
||||
public function __set($name, Folder $folder)
|
||||
public function __set($name, self $folder)
|
||||
{
|
||||
$this->folders[$name] = $folder;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Folder;
|
||||
|
||||
interface FolderInterface
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Folder;
|
||||
|
||||
use Laminas\Mail\Storage;
|
||||
use Laminas\Mail\Storage\Exception;
|
||||
use Laminas\Mail\Storage\ParamsNormalizer;
|
||||
use Laminas\Stdlib\ErrorHandler;
|
||||
|
||||
class Maildir extends Storage\Maildir implements FolderInterface
|
||||
@@ -52,20 +47,27 @@ class Maildir extends Storage\Maildir implements FolderInterface
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = (object) $params;
|
||||
$params = ParamsNormalizer::normalizeParams($params);
|
||||
|
||||
if (! isset($params['dirname'])) {
|
||||
throw new Exception\InvalidArgumentException('no dirname provided in params');
|
||||
}
|
||||
|
||||
if (! isset($params->dirname) || ! is_dir($params->dirname)) {
|
||||
throw new Exception\InvalidArgumentException('no valid dirname given in params');
|
||||
$dirname = (string) $params['dirname'];
|
||||
|
||||
if (! is_dir($dirname)) {
|
||||
throw new Exception\InvalidArgumentException('$dirname provided in params is not a directory');
|
||||
}
|
||||
|
||||
$this->rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$this->rootdir = rtrim($dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->delim = isset($params->delim) ? $params->delim : '.';
|
||||
$delim = $params['delim'] ?? '.';
|
||||
$this->delim = (string) $delim;
|
||||
|
||||
$folder = $params['folder'] ?? 'INBOX';
|
||||
|
||||
$this->buildFolderTree();
|
||||
$this->selectFolder(! empty($params->folder) ? $params->folder : 'INBOX');
|
||||
$this->selectFolder((string) $folder);
|
||||
$this->has['top'] = true;
|
||||
$this->has['flags'] = true;
|
||||
}
|
||||
@@ -155,10 +157,15 @@ class Maildir extends Storage\Maildir implements FolderInterface
|
||||
$subname = trim($rootFolder, $this->delim);
|
||||
|
||||
while ($currentFolder) {
|
||||
ErrorHandler::start(E_NOTICE);
|
||||
list($entry, $subname) = explode($this->delim, $subname, 2);
|
||||
ErrorHandler::stop();
|
||||
if (false !== strpos($subname, $this->delim)) {
|
||||
list($entry, $subname) = explode($this->delim, $subname, 2);
|
||||
} else {
|
||||
$entry = $subname;
|
||||
$subname = null;
|
||||
}
|
||||
|
||||
$currentFolder = $currentFolder->$entry;
|
||||
|
||||
if (! $subname) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Folder;
|
||||
|
||||
use Laminas\Mail\Storage;
|
||||
use Laminas\Mail\Storage\Exception;
|
||||
use Laminas\Mail\Storage\ParamsNormalizer;
|
||||
use Laminas\Stdlib\ErrorHandler;
|
||||
|
||||
class Mbox extends Storage\Mbox implements FolderInterface
|
||||
@@ -43,27 +38,33 @@ class Mbox extends Storage\Mbox implements FolderInterface
|
||||
* - dirname rootdir of mbox structure
|
||||
* - folder initial selected folder, default is 'INBOX'
|
||||
*
|
||||
* @param $params array mail reader specific parameters
|
||||
* @param $params array|object Array, iterable object, or stdClass object
|
||||
* with reader specific parameters
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = (object) $params;
|
||||
}
|
||||
$params = ParamsNormalizer::normalizeParams($params);
|
||||
|
||||
if (isset($params->filename)) {
|
||||
if (isset($params['filename'])) {
|
||||
throw new Exception\InvalidArgumentException(sprintf('use %s for a single file', Storage\Mbox::class));
|
||||
}
|
||||
|
||||
if (! isset($params->dirname) || ! is_dir($params->dirname)) {
|
||||
throw new Exception\InvalidArgumentException('no valid dirname given in params');
|
||||
if (! isset($params['dirname'])) {
|
||||
throw new Exception\InvalidArgumentException('no dirname provided in params');
|
||||
}
|
||||
|
||||
$this->rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$dirname = (string) $params['dirname'];
|
||||
|
||||
if (! is_dir($dirname)) {
|
||||
throw new Exception\InvalidArgumentException('$dirname provided in params is not a directory');
|
||||
}
|
||||
|
||||
$this->rootdir = rtrim($dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$folder = $params['folder'] ?? 'INBOX';
|
||||
|
||||
$this->buildFolderTree($this->rootdir);
|
||||
$this->selectFolder(! empty($params->folder) ? $params->folder : 'INBOX');
|
||||
$this->selectFolder((string) $folder);
|
||||
$this->has['top'] = true;
|
||||
$this->has['uniqueid'] = false;
|
||||
}
|
||||
@@ -130,10 +131,15 @@ class Mbox extends Storage\Mbox implements FolderInterface
|
||||
$currentFolder = $this->rootFolder;
|
||||
$subname = trim($rootFolder, DIRECTORY_SEPARATOR);
|
||||
while ($currentFolder) {
|
||||
ErrorHandler::start(E_NOTICE);
|
||||
list($entry, $subname) = explode(DIRECTORY_SEPARATOR, $subname, 2);
|
||||
ErrorHandler::stop();
|
||||
if (false !== strpos($subname, DIRECTORY_SEPARATOR)) {
|
||||
list($entry, $subname) = explode(DIRECTORY_SEPARATOR, $subname, 2);
|
||||
} else {
|
||||
$entry = $subname;
|
||||
$subname = null;
|
||||
}
|
||||
|
||||
$currentFolder = $currentFolder->$entry;
|
||||
|
||||
if (! $subname) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Laminas\Mail;
|
||||
@@ -121,7 +115,7 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W
|
||||
|
||||
$flags = [];
|
||||
foreach ($data['FLAGS'] as $flag) {
|
||||
$flags[] = isset(static::$knownFlags[$flag]) ? static::$knownFlags[$flag] : $flag;
|
||||
$flags[] = static::$knownFlags[$flag] ?? $flag;
|
||||
}
|
||||
|
||||
return new $this->messageClass(['handler' => $this, 'id' => $id, 'headers' => $header, 'flags' => $flags]);
|
||||
@@ -180,17 +174,14 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W
|
||||
* - ssl 'SSL' or 'TLS' for secure sockets
|
||||
* - folder select this folder [optional, default = 'INBOX']
|
||||
*
|
||||
* @param array|Protocol\Imap $params mail reader specific parameters or configured Imap protocol object
|
||||
* @param array|object|Protocol\Imap $params mail reader specific
|
||||
* parameters or configured Imap protocol object
|
||||
* @throws Exception\RuntimeException
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @throws Protocol\Exception\RuntimeException
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = (object) $params;
|
||||
}
|
||||
|
||||
$this->has['flags'] = true;
|
||||
|
||||
if ($params instanceof Protocol\Imap) {
|
||||
@@ -203,26 +194,37 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W
|
||||
return;
|
||||
}
|
||||
|
||||
if (! isset($params->user)) {
|
||||
$params = ParamsNormalizer::normalizeParams($params);
|
||||
|
||||
if (! isset($params['user'])) {
|
||||
throw new Exception\InvalidArgumentException('need at least user in params');
|
||||
}
|
||||
|
||||
$host = isset($params->host) ? $params->host : 'localhost';
|
||||
$password = isset($params->password) ? $params->password : '';
|
||||
$port = isset($params->port) ? $params->port : null;
|
||||
$ssl = isset($params->ssl) ? $params->ssl : false;
|
||||
$host = $params['host'] ?? 'localhost';
|
||||
$password = $params['password'] ?? '';
|
||||
$port = $params['port'] ?? null;
|
||||
$ssl = $params['ssl'] ?? false;
|
||||
$folder = $params['folder'] ?? 'INBOX';
|
||||
|
||||
if (null !== $port) {
|
||||
$port = (int) $port;
|
||||
}
|
||||
|
||||
if (! is_string($ssl)) {
|
||||
$ssl = (bool) $ssl;
|
||||
}
|
||||
|
||||
$this->protocol = new Protocol\Imap();
|
||||
|
||||
if (isset($params->novalidatecert)) {
|
||||
$this->protocol->setNoValidateCert((bool)$params->novalidatecert);
|
||||
if (array_key_exists('novalidatecert', $params)) {
|
||||
$this->protocol->setNoValidateCert((bool) $params['novalidatecert']);
|
||||
}
|
||||
|
||||
$this->protocol->connect($host, $port, $ssl);
|
||||
if (! $this->protocol->login($params->user, $password)) {
|
||||
$this->protocol->connect((string) $host, $port, $ssl);
|
||||
if (! $this->protocol->login((string) $params['user'], (string) $password)) {
|
||||
throw new Exception\RuntimeException('cannot login, user or password wrong');
|
||||
}
|
||||
$this->selectFolder(isset($params->folder) ? $params->folder : 'INBOX');
|
||||
$this->selectFolder((string) $folder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Laminas\Mail;
|
||||
@@ -112,12 +106,12 @@ class Maildir extends AbstractStorage
|
||||
{
|
||||
if ($id !== null) {
|
||||
$filedata = $this->getFileData($id);
|
||||
return isset($filedata['size']) ? $filedata['size'] : filesize($filedata['filename']);
|
||||
return $filedata['size'] ?? filesize($filedata['filename']);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($this->files as $num => $data) {
|
||||
$result[$num + 1] = isset($data['size']) ? $data['size'] : filesize($data['filename']);
|
||||
$result[$num + 1] = $data['size'] ?? filesize($data['filename']);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -215,26 +209,31 @@ class Maildir extends AbstractStorage
|
||||
* Supported parameters are:
|
||||
* - dirname dirname of mbox file
|
||||
*
|
||||
* @param $params array mail reader specific parameters
|
||||
* @param $params array|object Array, iterable object, or stdClass object
|
||||
* with reader specific parameters
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = (object) $params;
|
||||
$params = ParamsNormalizer::normalizeParams($params);
|
||||
|
||||
if (! isset($params['dirname'])) {
|
||||
throw new Exception\InvalidArgumentException('no dirname provided in params');
|
||||
}
|
||||
|
||||
if (! isset($params->dirname) || ! is_dir($params->dirname)) {
|
||||
throw new Exception\InvalidArgumentException('no valid dirname given in params');
|
||||
$dirname = (string) $params['dirname'] ;
|
||||
|
||||
if (! is_dir($dirname)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf('Maildir "%s" is not a directory', $dirname));
|
||||
}
|
||||
|
||||
if (! $this->isMaildir($params->dirname)) {
|
||||
if (! $this->isMaildir($dirname)) {
|
||||
throw new Exception\InvalidArgumentException('invalid maildir given');
|
||||
}
|
||||
|
||||
$this->has['top'] = true;
|
||||
$this->has['flags'] = true;
|
||||
$this->openMaildir($params->dirname);
|
||||
$this->openMaildir($dirname);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,21 +299,35 @@ class Maildir extends AbstractStorage
|
||||
continue;
|
||||
}
|
||||
|
||||
ErrorHandler::start(E_NOTICE);
|
||||
list($uniq, $info) = explode(':', $entry, 2);
|
||||
list(, $size) = explode(',', $uniq, 2);
|
||||
ErrorHandler::stop();
|
||||
if ($size && $size[0] == 'S' && $size[1] == '=') {
|
||||
if (false !== strpos($entry, ':')) {
|
||||
list($uniq, $info) = explode(':', $entry, 2);
|
||||
} else {
|
||||
$uniq = $entry;
|
||||
$info = '';
|
||||
}
|
||||
|
||||
if (false !== strpos($uniq, ',')) {
|
||||
list(, $size) = explode(',', $uniq, 2);
|
||||
} else {
|
||||
$size = '';
|
||||
}
|
||||
|
||||
if (strlen($size) >= 2 && $size[0] === 'S' && $size[1] === '=') {
|
||||
$size = substr($size, 2);
|
||||
}
|
||||
|
||||
if (! ctype_digit($size)) {
|
||||
$size = null;
|
||||
}
|
||||
|
||||
ErrorHandler::start(E_NOTICE);
|
||||
list($version, $flags) = explode(',', $info, 2);
|
||||
ErrorHandler::stop();
|
||||
if ($version != 2) {
|
||||
if (false !== strpos($info, ',')) {
|
||||
list($version, $flags) = explode(',', $info, 2);
|
||||
} else {
|
||||
$version = $info;
|
||||
$flags = '';
|
||||
}
|
||||
|
||||
if ($version !== '2') {
|
||||
$flags = '';
|
||||
}
|
||||
|
||||
@@ -322,21 +335,22 @@ class Maildir extends AbstractStorage
|
||||
$length = strlen($flags);
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$flag = $flags[$i];
|
||||
$namedFlags[$flag] = isset(static::$knownFlags[$flag]) ? static::$knownFlags[$flag] : $flag;
|
||||
$namedFlags[$flag] = static::$knownFlags[$flag] ?? $flag;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'uniq' => $uniq,
|
||||
'flags' => $namedFlags,
|
||||
'flaglookup' => array_flip($namedFlags),
|
||||
'filename' => $dirname . $entry
|
||||
'filename' => $dirname . $entry,
|
||||
];
|
||||
if ($size !== null) {
|
||||
$data['size'] = (int) $size;
|
||||
}
|
||||
$this->files[] = $data;
|
||||
}
|
||||
\usort($this->files, function ($a, $b) {
|
||||
|
||||
\usort($this->files, function ($a, $b): int {
|
||||
return \strcmp($a['filename'], $b['filename']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Laminas\Stdlib\ErrorHandler;
|
||||
@@ -115,7 +109,7 @@ class Mbox extends AbstractStorage
|
||||
$messageClassParams = [
|
||||
'file' => $this->fh,
|
||||
'startPos' => $messagePos['start'],
|
||||
'endPos' => $messagePos['end']
|
||||
'endPos' => $messagePos['end'],
|
||||
];
|
||||
|
||||
if (isset($this->messageEOL)) {
|
||||
@@ -125,16 +119,21 @@ class Mbox extends AbstractStorage
|
||||
return new $this->messageClass($messageClassParams);
|
||||
}
|
||||
|
||||
$bodyLines = 0; // TODO: need a way to change that
|
||||
/** @todo Uncomment once we know how to count body lines */
|
||||
// $bodyLines = 0;
|
||||
|
||||
$message = $this->getRawHeader($id);
|
||||
// file pointer is after headers now
|
||||
|
||||
/* Once we know how to count body lines, we should uncomment the
|
||||
* following, which would append the body content to the headers.
|
||||
*
|
||||
if ($bodyLines) {
|
||||
$message .= "\n";
|
||||
while ($bodyLines-- && ftell($this->fh) < $this->positions[$id - 1]['end']) {
|
||||
$message .= fgets($this->fh);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return new $this->messageClass(['handler' => $this, 'id' => $id, 'headers' => $message]);
|
||||
}
|
||||
@@ -184,24 +183,22 @@ class Mbox extends AbstractStorage
|
||||
* Supported parameters are:
|
||||
* - filename filename of mbox file
|
||||
*
|
||||
* @param $params array mail reader specific parameters
|
||||
* @param $params array|object|Config mail reader specific parameters
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = (object) $params;
|
||||
}
|
||||
$params = ParamsNormalizer::normalizeParams($params);
|
||||
|
||||
if (! isset($params->filename)) {
|
||||
if (! isset($params['filename'])) {
|
||||
throw new Exception\InvalidArgumentException('no valid filename given in params');
|
||||
}
|
||||
|
||||
if (isset($params->messageEOL)) {
|
||||
$this->messageEOL = (string) $params->messageEOL;
|
||||
if (isset($params['messageEOL'])) {
|
||||
$this->messageEOL = (string) $params['messageEOL'];
|
||||
}
|
||||
|
||||
$this->openMboxFile($params->filename);
|
||||
$this->openMboxFile((string) $params['filename']);
|
||||
$this->has['top'] = true;
|
||||
$this->has['uniqueid'] = false;
|
||||
}
|
||||
@@ -306,13 +303,12 @@ class Mbox extends AbstractStorage
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
ErrorHandler::start(E_WARNING);
|
||||
fclose($this->fh);
|
||||
ErrorHandler::stop();
|
||||
if (is_resource($this->fh)) {
|
||||
fclose($this->fh);
|
||||
}
|
||||
$this->positions = [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Waste some CPU cycles doing nothing.
|
||||
*
|
||||
@@ -323,7 +319,6 @@ class Mbox extends AbstractStorage
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* stub for not supported message deletion
|
||||
*
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Laminas\Stdlib\ErrorHandler;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Message;
|
||||
|
||||
use Laminas\Mail\Storage\Part;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Message;
|
||||
|
||||
interface MessageInterface
|
||||
|
||||
37
lib/laminas/laminas-mail/src/Storage/ParamsNormalizer.php
Normal file
37
lib/laminas/laminas-mail/src/Storage/ParamsNormalizer.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Traversable;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ParamsNormalizer
|
||||
{
|
||||
/**
|
||||
* @param mixed $params
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function normalizeParams($params): array
|
||||
{
|
||||
if ($params instanceof Traversable) {
|
||||
$params = iterator_to_array($params);
|
||||
}
|
||||
|
||||
if (is_object($params)) {
|
||||
$params = get_object_vars($params);
|
||||
}
|
||||
|
||||
if (! is_array($params)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid $params provided; expected array|Traversable|object, received %s',
|
||||
gettype($params)
|
||||
));
|
||||
}
|
||||
|
||||
Assert::isMap($params, 'Expected $params to have only string keys');
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Laminas\Mail\Header\HeaderInterface;
|
||||
use Laminas\Mail\Headers;
|
||||
use Laminas\Mime;
|
||||
use RecursiveIterator;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
class Part implements RecursiveIterator, Part\PartInterface
|
||||
{
|
||||
@@ -92,7 +87,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
$this->messageNum = $params['id'];
|
||||
}
|
||||
|
||||
$params['strict'] = isset($params['strict']) ? $params['strict'] : false;
|
||||
$params['strict'] = $params['strict'] ?? false;
|
||||
|
||||
if (isset($params['raw'])) {
|
||||
Mime\Decode::splitMessage(
|
||||
@@ -134,7 +129,6 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Body of part
|
||||
*
|
||||
@@ -168,7 +162,6 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
return strlen($this->getContent());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cache content and split in parts if multipart
|
||||
*
|
||||
@@ -315,12 +308,12 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
if ($header instanceof HeaderInterface) {
|
||||
$return = $header->getFieldValue(HeaderInterface::FORMAT_RAW);
|
||||
} else {
|
||||
$return = '';
|
||||
foreach ($header as $h) {
|
||||
$return .= $h->getFieldValue(HeaderInterface::FORMAT_RAW)
|
||||
. Mime\Mime::LINEEND;
|
||||
}
|
||||
$return = trim($return, Mime\Mime::LINEEND);
|
||||
$return = trim(implode(
|
||||
Mime\Mime::LINEEND,
|
||||
array_map(static function ($header): string {
|
||||
return $header->getFieldValue(HeaderInterface::FORMAT_RAW);
|
||||
}, iterator_to_array($header))
|
||||
), Mime\Mime::LINEEND);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
@@ -406,10 +399,11 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
*
|
||||
* @return bool current element has children/is multipart
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function hasChildren()
|
||||
{
|
||||
$current = $this->current();
|
||||
return $current && $current instanceof Part && $current->isMultipart();
|
||||
return $current && $current instanceof self && $current->isMultipart();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,6 +411,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
*
|
||||
* @return Part same as self::current()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->current();
|
||||
@@ -427,6 +422,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
*
|
||||
* @return bool check if there's a current element
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
if ($this->countParts === null) {
|
||||
@@ -438,6 +434,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
/**
|
||||
* implements Iterator::next()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
++$this->iterationPos;
|
||||
@@ -448,6 +445,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
*
|
||||
* @return string key/number of current part
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return $this->iterationPos;
|
||||
@@ -458,6 +456,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
*
|
||||
* @return Part current part
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->getPart($this->iterationPos);
|
||||
@@ -466,6 +465,7 @@ class Part implements RecursiveIterator, Part\PartInterface
|
||||
/**
|
||||
* implements Iterator::rewind()
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
$this->countParts();
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Part\Exception;
|
||||
|
||||
use Laminas\Mail\Storage\Exception\ExceptionInterface as StorageException;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Part\Exception;
|
||||
|
||||
use Laminas\Mail\Storage\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Part\Exception;
|
||||
|
||||
use Laminas\Mail\Storage\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Part;
|
||||
|
||||
use Laminas\Mail\Headers;
|
||||
@@ -48,7 +42,7 @@ class File extends Part
|
||||
fseek($this->fh, $params['startPos']);
|
||||
}
|
||||
$header = '';
|
||||
$endPos = isset($params['endPos']) ? $params['endPos'] : null;
|
||||
$endPos = $params['endPos'] ?? null;
|
||||
while (($endPos === null || ftell($this->fh) < $endPos) && trim($line = fgets($this->fh))) {
|
||||
$header .= $line;
|
||||
}
|
||||
@@ -151,7 +145,10 @@ class File extends Part
|
||||
throw new Exception\RuntimeException('part not found');
|
||||
}
|
||||
|
||||
return new static(['file' => $this->fh, 'startPos' => $this->partPos[$num][0],
|
||||
'endPos' => $this->partPos[$num][1]]);
|
||||
return new static([
|
||||
'file' => $this->fh,
|
||||
'startPos' => $this->partPos[$num][0],
|
||||
'endPos' => $this->partPos[$num][1],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Part;
|
||||
|
||||
use ArrayIterator;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage;
|
||||
|
||||
use Laminas\Mail\Exception as MailException;
|
||||
@@ -60,8 +54,12 @@ class Pop3 extends AbstractStorage
|
||||
$bodyLines = 0;
|
||||
$message = $this->protocol->top($id, $bodyLines, true);
|
||||
|
||||
return new $this->messageClass(['handler' => $this, 'id' => $id, 'headers' => $message,
|
||||
'noToplines' => $bodyLines < 1]);
|
||||
return new $this->messageClass([
|
||||
'handler' => $this,
|
||||
'id' => $id,
|
||||
'headers' => $message,
|
||||
'noToplines' => $bodyLines < 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -117,16 +115,13 @@ class Pop3 extends AbstractStorage
|
||||
* - port port for POP3 server [optional, default = 110]
|
||||
* - ssl 'SSL' or 'TLS' for secure sockets
|
||||
*
|
||||
* @param array|Protocol\Pop3 $params mail reader specific parameters or configured Pop3 protocol object
|
||||
* @param array|object|Protocol\Pop3 $params mail reader specific
|
||||
* parameters or configured Pop3 protocol object
|
||||
* @throws \Laminas\Mail\Storage\Exception\InvalidArgumentException
|
||||
* @throws \Laminas\Mail\Protocol\Exception\RuntimeException
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = (object) $params;
|
||||
}
|
||||
|
||||
$this->has['fetchPart'] = false;
|
||||
$this->has['top'] = null;
|
||||
$this->has['uniqueid'] = null;
|
||||
@@ -136,23 +131,33 @@ class Pop3 extends AbstractStorage
|
||||
return;
|
||||
}
|
||||
|
||||
if (! isset($params->user)) {
|
||||
$params = ParamsNormalizer::normalizeParams($params);
|
||||
|
||||
if (! isset($params['user'])) {
|
||||
throw new Exception\InvalidArgumentException('need at least user in params');
|
||||
}
|
||||
|
||||
$host = isset($params->host) ? $params->host : 'localhost';
|
||||
$password = isset($params->password) ? $params->password : '';
|
||||
$port = isset($params->port) ? $params->port : null;
|
||||
$ssl = isset($params->ssl) ? $params->ssl : false;
|
||||
$host = $params['host'] ?? 'localhost';
|
||||
$password = $params['password'] ?? '';
|
||||
$port = $params['port'] ?? null;
|
||||
$ssl = $params['ssl'] ?? false;
|
||||
|
||||
if (null !== $port) {
|
||||
$port = (int) $port;
|
||||
}
|
||||
|
||||
if (! is_string($ssl)) {
|
||||
$ssl = (bool) $ssl;
|
||||
}
|
||||
|
||||
$this->protocol = new Protocol\Pop3();
|
||||
|
||||
if (isset($params->novalidatecert)) {
|
||||
$this->protocol->setNoValidateCert((bool)$params->novalidatecert);
|
||||
if (array_key_exists('novalidatecert', $params)) {
|
||||
$this->protocol->setNoValidateCert((bool) $params['novalidatecert']);
|
||||
}
|
||||
|
||||
$this->protocol->connect($host, $port, $ssl);
|
||||
$this->protocol->login($params->user, $password);
|
||||
$this->protocol->connect((string) $host, $port, $ssl);
|
||||
$this->protocol->login((string) $params['user'], (string) $password);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Writable;
|
||||
|
||||
use Laminas\Mail\Exception as MailException;
|
||||
@@ -51,9 +45,9 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
throw new StorageException\InvalidArgumentException("parent $dir not found", 0, $error);
|
||||
} elseif (! is_dir($dir)) {
|
||||
throw new StorageException\InvalidArgumentException("parent $dir not a directory", 0, $error);
|
||||
} else {
|
||||
throw new StorageException\RuntimeException('cannot create maildir', 0, $error);
|
||||
}
|
||||
|
||||
throw new StorageException\RuntimeException('cannot create maildir', 0, $error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,10 +384,12 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
);
|
||||
}
|
||||
|
||||
return ['dirname' => $this->rootdir . '.' . $folder,
|
||||
'uniq' => $uniq,
|
||||
'filename' => $tmpdir . $uniq,
|
||||
'handle' => $fh];
|
||||
return [
|
||||
'dirname' => $this->rootdir . '.' . $folder,
|
||||
'uniq' => $uniq,
|
||||
'filename' => $tmpdir . $uniq,
|
||||
'handle' => $fh,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,9 +491,11 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$this->files[] = ['uniq' => $tempFile['uniq'],
|
||||
'flags' => $flags,
|
||||
'filename' => $newFilename];
|
||||
$this->files[] = [
|
||||
'uniq' => $tempFile['uniq'],
|
||||
'flags' => $flags,
|
||||
'filename' => $newFilename,
|
||||
];
|
||||
if ($this->quota) {
|
||||
$this->addQuotaEntry((int) $size, 1);
|
||||
}
|
||||
@@ -563,9 +561,11 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
if ($folder->getGlobalName() == $this->currentFolder
|
||||
|| ($this->currentFolder == 'INBOX' && $folder->getGlobalName() == '/')
|
||||
) {
|
||||
$this->files[] = ['uniq' => $tempFile['uniq'],
|
||||
'flags' => $flags,
|
||||
'filename' => $newFile];
|
||||
$this->files[] = [
|
||||
'uniq' => $tempFile['uniq'],
|
||||
'flags' => $flags,
|
||||
'filename' => $newFile,
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->quota) {
|
||||
@@ -650,7 +650,7 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
|
||||
// NOTE: double dirname to make sure we always move to cur. if recent
|
||||
// flag has been set (message is in new) it will be moved to cur.
|
||||
$newFilename = dirname(dirname($filedata['filename']))
|
||||
$newFilename = dirname($filedata['filename'], 2)
|
||||
. DIRECTORY_SEPARATOR
|
||||
. 'cur'
|
||||
. DIRECTORY_SEPARATOR
|
||||
@@ -841,9 +841,11 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
}
|
||||
}
|
||||
|
||||
return ['size' => $totalSize,
|
||||
'count' => $messages,
|
||||
'quota' => $quota];
|
||||
return [
|
||||
'size' => $totalSize,
|
||||
'count' => $messages,
|
||||
'quota' => $quota,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -921,10 +923,12 @@ class Maildir extends Folder\Maildir implements WritableInterface
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
return ['size' => $totalSize,
|
||||
'count' => $messages,
|
||||
'quota' => $quota,
|
||||
'over_quota' => $overQuota];
|
||||
return [
|
||||
'size' => $totalSize,
|
||||
'count' => $messages,
|
||||
'quota' => $quota,
|
||||
'over_quota' => $overQuota,
|
||||
];
|
||||
}
|
||||
|
||||
protected function addQuotaEntry($size, $count = 1)
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Storage\Writable;
|
||||
|
||||
use Laminas\Mail\Message;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Stdlib\AbstractOptions;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport\Exception;
|
||||
|
||||
use Laminas\Mail\Exception\ExceptionInterface as MailException;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport\Exception;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Stdlib\ArrayUtils;
|
||||
@@ -45,7 +39,7 @@ abstract class Factory
|
||||
));
|
||||
}
|
||||
|
||||
$type = isset($spec['type']) ? $spec['type'] : 'sendmail';
|
||||
$type = $spec['type'] ?? 'sendmail';
|
||||
|
||||
$normalizedType = strtolower($type);
|
||||
|
||||
@@ -61,7 +55,7 @@ abstract class Factory
|
||||
));
|
||||
}
|
||||
|
||||
$transport = new $type;
|
||||
$transport = new $type();
|
||||
|
||||
if (! $transport instanceof TransportInterface) {
|
||||
throw new Exception\DomainException(sprintf(
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Mail\Message;
|
||||
@@ -70,7 +64,7 @@ class File implements TransportInterface
|
||||
public function send(Message $message)
|
||||
{
|
||||
$options = $this->options;
|
||||
$filename = call_user_func($options->getCallback(), $this);
|
||||
$filename = $options->getCallback()($this);
|
||||
$file = $options->getPath() . DIRECTORY_SEPARATOR . $filename;
|
||||
$email = $message->toString();
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Mail\Message;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Mail;
|
||||
@@ -126,14 +120,14 @@ class Sendmail implements TransportInterface
|
||||
|
||||
// On *nix platforms, we need to replace \r\n with \n
|
||||
// sendmail is not an SMTP server, it is a unix command - it expects LF
|
||||
if (! $this->isWindowsOs()) {
|
||||
if (PHP_VERSION_ID < 80000 && ! $this->isWindowsOs()) {
|
||||
$to = str_replace("\r\n", "\n", $to);
|
||||
$subject = str_replace("\r\n", "\n", $subject);
|
||||
$body = str_replace("\r\n", "\n", $body);
|
||||
$headers = str_replace("\r\n", "\n", $headers);
|
||||
}
|
||||
|
||||
call_user_func($this->callable, $to, $subject, $body, $headers, $params);
|
||||
($this->callable)($to, $subject, $body, $headers, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Mail\Address;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Transport;
|
||||
|
||||
use Laminas\Mail\Exception;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user