N°5122 - Update libs to new PHP requirements

This commit is contained in:
Molkobain
2022-08-08 14:10:26 +02:00
parent 30021d9236
commit 57c36d0e51
585 changed files with 62279 additions and 20427 deletions

View File

@@ -0,0 +1,5 @@
{
"ignore_php_platform_requirements": {
"8.1": true
}
}

View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
INTL_EXTENSION=$(php -r 'echo sprintf("php%s.%s-intl",PHP_MAJOR_VERSION,PHP_MINOR_VERSION);')
echo -e "Removing $INTL_EXTENSION extension:\n"
sudo apt remove "$INTL_EXTENSION" -y
echo -e "Cleaning up:\n"
sudo apt autoclean && sudo apt autoremove
echo -e "Installed extensions:\n"
/usr/local/bin/php-extensions-with-version.php

View File

@@ -1,562 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 2.12.5 - 2020-12-31
-----
### Release Notes for [2.12.5](https://github.com/laminas/laminas-mail/milestone/9)
2.12.x bugfix release (patch)
### 2.12.5
- Total issues resolved: **0**
- Total pull requests resolved: **1**
- Total contributors: **1**
#### Bug
- [108: Fix Invalid header line for Content-Disposition string - incomplete continuation](https://github.com/laminas/laminas-mail/pull/108) thanks to @glensc
## 2.12.3 - TBD
### Added
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#107](https://github.com/laminas/laminas-mail/pull/107) corrects a return type annotation in Laminas\Mail\Address\AddressInterface and in implementer.
## 2.12.2 - 2020-08-06
### Added
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#103](https://github.com/laminas/laminas-mail/pull/103) fixes issues on Windows whereby the "Subject" and "To" headers were duplicated.
- [#104](https://github.com/laminas/laminas-mail/pull/104) fixes an issue that occured when the `Sendmail` transport was configured with a `-f` option (From address). Prior to the fix, the option would be overwritten by the message `From` or `Sender` headers, which could lead to errors on systems where all mail must be sent from a specific address. The fixed behavior is to always honor the `-f` option, and ignore the `From` and `Sender` headers if it was provided to the transport.
## 2.12.1 - 2020-08-05
### Added
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#102](https://github.com/laminas/laminas-mail/pull/102) corrects a parameter typehint and a return type within the `Protocol\Imap` subcomponent to correctly detail what they allow.
## 2.12.0 - 2020-07-30
### Added
- [#95](https://github.com/laminas/laminas-mail/pull/95) adds a new interface, `Laminas\Mail\Header\HeaderLocatorInterface`. This defines classes that will locate header classes based on an email header name.
- [#95](https://github.com/laminas/laminas-mail/pull/95) adds a new class, `Laminas\Mail\Header\HeaderLocator`, implementing `Laminas\Mail\Header\HeaderLocatorInterface`. This is the default implementation of that new interface.
- [#95](https://github.com/laminas/laminas-mail/pull/95) adds the methods `setHeaderLocator(Laminas\Mail\Header\HeaderLocatorInterface $locator)` and `getHeaderLocator(): Laminas\Mail\Header\HeaderLocatorInterface` to the `Laminas\Mail\Headers` implementation. Users are encouraged to use these when providing custom header implementations in order to prepare for a 3.0 release. **The value of `getHeaderLocator()` will now be used as the default mechanism for resolving header names to header classes.**
- [#94](https://github.com/laminas/laminas-mail/pull/94) and [#99](https://github.com/laminas/laminas-mail/pull/99) add the "novalidatecert" option for each of the POP3, IMAP, and SMTP protocol implementations. When toggled true, you can connect to servers using self-signed certificates.
### Changed
- [#95](https://github.com/laminas/laminas-mail/pull/95) bumps the minimum supported PHP version to 7.1.
### Deprecated
- [#99](https://github.com/laminas/laminas-mail/pull/99) deprecates the `Laminas\Mail\Protocol\AbstractProtocol::_connect()` method, as it is no longer used internally.
- [#95](https://github.com/laminas/laminas-mail/pull/95) deprecates `Laminas\Mail\Header\HeaderLoader` in favor of the new `Laminas\Mail\Header\HeaderLocator` class. The class will be removed in version 3.0.0.
- [#95](https://github.com/laminas/laminas-mail/pull/95) deprecates the `Headers::getPluginClassLoader()` and `Headers::setPluginClassLoader()` methods, in favor of the new `setHeaderLocator()` and `getHeaderLocator()` methods. These methods will be removed in version 3.0.0, and laminas-loader `PluginClassLocator` instances will no longer be supported. Please update your code to use the new `HeaderLocatorInterface` instead.
### Removed
- [#98](https://github.com/laminas/laminas-mail/pull/98) removes `Laminas\Mail\Transport\Null`, as it is unusable with the new minimum supported PHP version (7.1). Users should use `Laminas\Mail\Transport\InMemory` instead. As this has been the default when requesting a "null" transport from `Laminas\Mail\Transport\Factory` for the past several minor releases, end-users should be unaffected. However, **users are encouraged to specify "inmemory" instead of "null" when requiring a no-op transport.**
### Fixed
- Nothing.
## 2.11.1 - 2020-07-28
### Added
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#97](https://github.com/laminas/laminas-mail/pull/97) adds code to `Header\ContentType::addParameter()` to ensure the value is trimmed of whitespace, fixing issues whereby filenames might contain a leading or trailing space.
## 2.11.0 - 2020-06-30
### Added
- [#31](https://github.com/laminas/laminas-mail/pull/31) adds the class `Laminas\Main\Header\ContentDisposition`, which implements `Laminas\Mail\Header\UnstructuredInterface`, and which provides propery encoding and escaping for `Content-Disposition` mail headers.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#31](https://github.com/laminas/laminas-mail/pull/31) provides a fix to ensure that the `Content-Disposition` header is properly encoded.
## 2.10.2 - 2020-06-30
### Added
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#89](https://github.com/laminas/laminas-mail/pull/89) corrects two parameter typehints within the Storage subcomponent to correctly detail what they allow.
- [#93](https://github.com/laminas/laminas-mail/pull/93) fixes an issue whereby an address containing a `;` character was not getting quoted, causing it to be interpreted as an address separator instead of part of the address.
## 2.10.1 - 2020-04-21
### Added
- [#81](https://github.com/laminas/laminas-mail/pull/81) adds PHP 7.3 and 7.4 support.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#83](https://github.com/laminas/laminas-mail/pull/83) fixes PHPDocs in `Transport\InMemory` (last message can be `null`).
- [#84](https://github.com/laminas/laminas-mail/pull/84) fixes PHP 7.4 compatibility.
- [#82](https://github.com/laminas/laminas-mail/pull/82) fixes numerous issues in `Storage\Maildir`. This storage adapter was not working before and unit tests were disabled.
- [#75](https://github.com/laminas/laminas-mail/pull/75) fixes how `Laminas\Mail\Header\ListParser::parse()` parses the string with quotes.
- [#88](https://github.com/laminas/laminas-mail/pull/88) fixes recognising encoding of `Subject` and `GenericHeader` headers.
## 2.10.0 - 2018-06-07
### Added
- [zendframework/zend-mail#213](https://github.com/zendframework/zend-mail/pull/213) re-adds support for PHP 5.6 and 7.0; Laminas policy is never
to bump the major version of a PHP requirement unless the package is bumping major version.
- [zendframework/zend-mail#172](https://github.com/zendframework/zend-mail/pull/172) adds the flag `connection_time_limit` to the possible `Laminas\Mail\Transport\Smtp` options.
This flag, when provided as a positive integer, and in conjunction with the `use_complete_quit` flag, will
reconnect to the server after the specified interval.
- [zendframework/zend-mail#166](https://github.com/zendframework/zend-mail/pull/166) adds functionality for handling `References` and `In-Reply-To` headers.
- [zendframework/zend-mail#148](https://github.com/zendframework/zend-mail/pull/148) adds the optional constructor argument `$comment` and the method `getComment()` to the class
`Laminas\Mail\Address`. When a comment is present, `toString()` will include it in the representation.
- [zendframework/zend-mail#148](https://github.com/zendframework/zend-mail/pull/148) adds the method `Laminas\Mail\Address::fromString(string $address, $comment = null) : Address`.
The method can be used to generate an instance from a string containing a `(name)?<email>` value.
The `$comment` argument can be used to associate a comment with the address.
### Changed
- [zendframework/zend-mail#196](https://github.com/zendframework/zend-mail/pull/196) updates how the `Headers::fromString()` handles header line continuations
that include a single empty line, ensuring they are concatenated to the
header value.
- [zendframework/zend-mail#165](https://github.com/zendframework/zend-mail/pull/165) changes the `AbstractAddressList` IDN&lt;-&gt;ASCII conversion; it now no longer requires
ext-intl, but instead uses a bundled true/punycode library to accomplish it. This also means that
the conversions will work on any PHP installation.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#211](https://github.com/zendframework/zend-mail/pull/211) fixes how the `ContentType` header class parses the value it receives. Previously,
it was incorrectly splitting the value on semi-colons that were inside quotes; in now correctly
ignores them.
- [zendframework/zend-mail#204](https://github.com/zendframework/zend-mail/pull/204) fixes `HeaderWrap::mimeDecodeValue()` behavior when handling a multiline UTF-8
header split across a character. The fix will only work when ext-imap is present, however.
- [zendframework/zend-mail#164](https://github.com/zendframework/zend-mail/pull/164) fixes the return value from `Laminas\Mail\Protocol\Imap::capability()` when no response is
returned from the server; previously, it returned `false`, but now correctly returns an empty array.
- [zendframework/zend-mail#148](https://github.com/zendframework/zend-mail/pull/148) fixes how `Laminas\Mail\Header\AbstractAddressList` parses address values, ensuring
that they now retain any address comment discovered to include in the generated `Laminas\Mail\Address` instances.
- [zendframework/zend-mail#147](https://github.com/zendframework/zend-mail/pull/147) fixes how address lists are parsed, expanding the functionality to allow either
`,` or `;` delimiters (or both in combination).
## 2.9.0 - 2017-03-01
### Added
- [zendframework/zend-mail#177](https://github.com/zendframework/zend-mail/issues/177)
[zendframework/zend-mail#181](https://github.com/zendframework/zend-mail/pull/181)
[zendframework/zend-mail#192](https://github.com/zendframework/zend-mail/pull/192)
[zendframework/zend-mail#189](https://github.com/zendframework/zend-mail/pull/189) PHP 7.2 support
- [zendframework/zend-mail#73](https://github.com/zendframework/zend-mail/issues/73)
[zendframework/zend-mail#160](https://github.com/zendframework/zend-mail/pull/160) Support for
mails that don't have a `To`, as long as `Cc` or `Bcc` are set.
- [zendframework/zend-mail#161](https://github.com/zendframework/zend-mail/issues/161) removed
useless try-catch that just re-throws.
- [zendframework/zend-mail#134](https://github.com/zendframework/zend-mail/issues/134) simplified
checks for the existence of some string sub-sequences, which were
needlessly performed via regular expressions
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#188](https://github.com/zendframework/zend-mail/pull/188) split strings
before calling `iconv_mime_decode()`, which destroys newlines, rendering
DKIM parsing useless.
- [zendframework/zend-mail#156](https://github.com/zendframework/zend-mail/pull/156) fixed a
regression in which `<` and `>` would appear doubled in message
identifiers.
- [zendframework/zend-mail#143](https://github.com/zendframework/zend-mail/pull/143) fixed parsing
of `<` and `>` being part of the email address comment.
## 2.8.0 - 2017-06-08
### Added
- [zendframework/zend-mail#117](https://github.com/zendframework/zend-mail/pull/117) adds support
configuring whether or not an SMTP transport should issue a `QUIT` at
`__destruct()` and/or end of script execution. Use the `use_complete_quit`
configuration flag and/or the `setuseCompleteQuit($flag)` method to change
the setting (default is to enable this behavior, which was the previous
behavior).
- [zendframework/zend-mail#128](https://github.com/zendframework/zend-mail/pull/128) adds a
requirement on ext/iconv, as it is used internally.
- [zendframework/zend-mail#132](https://github.com/zendframework/zend-mail/pull/132) bumps minimum
php version to 5.6
- [zendframework/zend-mail#144](https://github.com/zendframework/zend-mail/pull/144) adds support
for TLS versions 1.1 and 1.2 for all protocols supporting TLS operations.
### Changed
- [zendframework/zend-mail#140](https://github.com/zendframework/zend-mail/pull/140) updates the
`Sendmail` transport such that `From` and `Sender` addresses are passed to
`escapeshellarg()` when forming the `-f` argument for the `sendmail` binary.
While malformed addresses should never reach this class, this extra hardening
helps ensure safety in cases where a developer codes their own
`AddressInterface` implementations for these types of addresses.
- [zendframework/zend-mail#141](https://github.com/zendframework/zend-mail/pull/141) updates
`Laminas\Mail\Message::getHeaders()` to throw an exception in a case where the
`$headers` property is not a `Headers` instance.
- [zendframework/zend-mail#150](https://github.com/zendframework/zend-mail/pull/150) updates the
`Smtp` protocol to allow an empty or `none` value for the SSL configuration
value.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#151](https://github.com/zendframework/zend-mail/pull/151) fixes a condition
in the `Sendmail` transport whereby CLI parameters were not properly trimmed.
## 2.7.3 - 2017-02-14
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#93](https://github.com/zendframework/zend-mail/pull/93) fixes a situation
whereby `getSender()` was unintentionally creating a blank `Sender` header,
instead of returning `null` if none exists, fixing an issue in the SMTP
transport.
- [zendframework/zend-mail#105](https://github.com/zendframework/zend-mail/pull/105) fixes the header
implementation to allow zero (`0`) values for header values.
- [zendframework/zend-mail#116](https://github.com/zendframework/zend-mail/pull/116) fixes how the
`AbstractProtocol` handles `stream_socket_client()` errors, ensuring an
exception is thrown with detailed information regarding the failure.
## 2.7.2 - 2016-12-19
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- Fixes [ZF2016-04](https://framework.zend.com/security/advisory/ZF2016-04).
## 2.7.1 - 2016-05-09
### Added
- [zendframework/zend-mail#38](https://github.com/zendframework/zend-mail/pull/38) adds support in the
IMAP protocol adapter for fetching items by UID.
- [zendframework/zend-mail#88](https://github.com/zendframework/zend-mail/pull/88) adds and publishes
documentation to https://docs.laminas.dev/laminas-mail/
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#9](https://github.com/zendframework/zend-mail/pull/9) fixes the
`Laminas\Mail\Header\Sender::fromString()` implementation to more closely follow
the ABNF defined in RFC-5322, specifically to allow addresses in the form
`user@domain` (with no TLD).
- [zendframework/zend-mail#28](https://github.com/zendframework/zend-mail/pull/28) and
[zendframework/zend-mail#87](https://github.com/zendframework/zend-mail/pull/87) fix header value
validation when headers wrap using the sequence `\r\n\t`; prior to this
release, such sequences incorrectly marked a header value invalid.
- [zendframework/zend-mail#37](https://github.com/zendframework/zend-mail/pull/37) ensures that empty
lines do not result in PHP errors when consuming messages from a Courier IMAP
server.
- [zendframework/zend-mail#81](https://github.com/zendframework/zend-mail/pull/81) fixes the validation
in `Laminas\Mail\Address` to also DNS hostnames as well as local addresses.
## 2.7.0 - 2016-04-11
### Added
- [zendframework/zend-mail#41](https://github.com/zendframework/zend-mail/pull/41) adds support for
IMAP delimiters in the IMAP storage adapter.
- [zendframework/zend-mail#80](https://github.com/zendframework/zend-mail/pull/80) adds:
- `Laminas\Mail\Protocol\SmtpPluginManagerFactory`, for creating and returning an
`SmtpPluginManagerFactory` instance.
- `Laminas\Mail\ConfigProvider`, which maps the `SmtpPluginManager` to the above
factory.
- `Laminas\Mail\Module`, which does the same, for laminas-mvc contexts.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- Nothing.
## 2.6.2 - 2016-04-11
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#44](https://github.com/zendframework/zend-mail/pull/44) fixes an issue with
decoding of addresses where the full name contains a comma (e.g., "Lastname,
Firstname").
- [zendframework/zend-mail#45](https://github.com/zendframework/zend-mail/pull/45) ensures that the
message parser allows deserializing message bodies containing multiple EOL
sequences.
- [zendframework/zend-mail#78](https://github.com/zendframework/zend-mail/pull/78) fixes the logic of
`HeaderWrap::canBeEncoded()` to ensure it returns correctly for header lines
containing at least one multibyte character, and particularly when that
character falls at specific locations (per a
[reported bug at php.net](https://bugs.php.net/bug.php?id=53891)).
## 2.6.1 - 2016-02-24
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#72](https://github.com/zendframework/zend-mail/pull/72) re-implements
`SmtpPluginManager` as a laminas-servicemanager `AbstractPluginManager`, after
reports that making it standalone broke important extensibility use cases
(specifically, replacing existing plugins and/or providing additional plugins
could only be managed with significant code changes).
## 2.6.0 - 2016-02-18
### Added
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#47](https://github.com/zendframework/zend-mail/pull/47) updates the
component to remove the (soft) dependency on laminas-servicemanager, by
altering the `SmtpPluginManager` to implement container-interop's
`ContainerInterface` instead of extending from `AbstractPluginManager`.
Usage remains the same, though developers who were adding services
to the plugin manager will need to instead extend it now.
- [zendframework/zend-mail#70](https://github.com/zendframework/zend-mail/pull/70) updates dependencies
to stable, forwards-compatible versions, and removes unused dependencies.
## 2.5.2 - 2015-09-10
### Added
- [zendframework/zend-mail#12](https://github.com/zendframework/zend-mail/pull/12) adds support for
simple comments in address lists.
- [zendframework/zend-mail#13](https://github.com/zendframework/zend-mail/pull/13) adds support for
groups in address lists.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [zendframework/zend-mail#26](https://github.com/zendframework/zend-mail/pull/26) fixes the
`ContentType` header to properly handle parameters with encoded values.
- [zendframework/zend-mail#11](https://github.com/zendframework/zend-mail/pull/11) fixes the
behavior of the `Sender` header, ensuring it can handle domains that do not
contain a TLD, as well as addresses referencing mailboxes (no domain).
- [zendframework/zend-mail#24](https://github.com/zendframework/zend-mail/pull/24) fixes parsing of
mail messages that contain an initial blank line (prior to the headers), a
situation observed in particular with GMail.

View File

@@ -1,7 +1,6 @@
# laminas-mail
[![Build Status](https://travis-ci.com/laminas/laminas-mail.svg?branch=master)](https://travis-ci.com/laminas/laminas-mail)
[![Coverage Status](https://coveralls.io/repos/github/laminas/laminas-mail/badge.svg?branch=master)](https://coveralls.io/github/laminas/laminas-mail?branch=master)
[![Build Status](https://github.com/laminas/laminas-mail/workflows/Continuous%20Integration/badge.svg)](https://github.com/laminas/laminas-mail/actions?query=workflow%3A"Continuous+Integration")
`Laminas\Mail` provides generalized functionality to compose and send both text and
MIME-compliant multipart email messages. Mail can be sent with `Laminas\Mail` via

View File

@@ -1,22 +1,48 @@
{
"name": "laminas/laminas-mail",
"description": "Provides generalized functionality to compose and send both text and MIME-compliant multipart e-mail messages",
"license": "BSD-3-Clause",
"keywords": [
"laminas",
"mail"
],
"homepage": "https://laminas.dev",
"support": {
"docs": "https://docs.laminas.dev/laminas-mail/",
"issues": "https://github.com/laminas/laminas-mail/issues",
"source": "https://github.com/laminas/laminas-mail",
"rss": "https://github.com/laminas/laminas-mail/releases.atom",
"chat": "https://laminas.dev/chat",
"forum": "https://discourse.laminas.dev"
"license": "BSD-3-Clause",
"require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"ext-iconv": "*",
"laminas/laminas-loader": "^2.8",
"laminas/laminas-mime": "^2.9.1",
"laminas/laminas-stdlib": "^3.6",
"laminas/laminas-validator": "^2.15",
"symfony/polyfill-mbstring": "^1.12.0",
"webmozart/assert": "^1.10",
"symfony/polyfill-intl-idn": "^1.24.0"
},
"conflict": {
"zendframework/zend-mail": "*"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-crypt": "^2.6 || ^3.4",
"laminas/laminas-db": "^2.13.3",
"laminas/laminas-servicemanager": "^3.7",
"phpunit/phpunit": "^9.5.5",
"psalm/plugin-phpunit": "^0.15.1",
"symfony/process": "^5.3.7",
"vimeo/psalm": "^4.7"
},
"suggest": {
"laminas/laminas-crypt": "Crammd5 support in SMTP Auth",
"laminas/laminas-servicemanager": "^2.7.10 || ^3.3.1 when using SMTP to deliver messages"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true
},
"platform": {
"php": "7.3.99"
}
},
"extra": {
"laminas": {
@@ -24,27 +50,6 @@
"config-provider": "Laminas\\Mail\\ConfigProvider"
}
},
"require": {
"php": "^7.1",
"ext-iconv": "*",
"laminas/laminas-loader": "^2.5",
"laminas/laminas-mime": "^2.5",
"laminas/laminas-stdlib": "^2.7 || ^3.0",
"laminas/laminas-validator": "^2.10.2",
"laminas/laminas-zendframework-bridge": "^1.0",
"true/punycode": "^2.1"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-config": "^2.6",
"laminas/laminas-crypt": "^2.6 || ^3.0",
"laminas/laminas-servicemanager": "^3.2.1",
"phpunit/phpunit": "^7.5.20"
},
"suggest": {
"laminas/laminas-crypt": "Crammd5 support in SMTP Auth",
"laminas/laminas-servicemanager": "^2.7.10 || ^3.3.1 when using SMTP to deliver messages"
},
"autoload": {
"psr-4": {
"Laminas\\Mail\\": "src/"
@@ -58,14 +63,21 @@
"scripts": {
"check": [
"@cs-check",
"@static-analysis",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"static-analysis": "psalm --shepherd --stats",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
},
"replace": {
"zendframework/zend-mail": "^2.10.0"
"support": {
"issues": "https://github.com/laminas/laminas-mail/issues",
"forum": "https://discourse.laminas.dev",
"chat": "https://laminas.dev/chat",
"source": "https://github.com/laminas/laminas-mail",
"docs": "https://docs.laminas.dev/laminas-mail/",
"rss": "https://github.com/laminas/laminas-mail/releases.atom"
}
}

4882
lib/laminas/laminas-mail/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -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;
/**

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -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;
/**

View File

@@ -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;
/**

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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 . '"';
}
}
}

View File

@@ -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

View File

@@ -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;
}
/**

View File

@@ -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;
/**

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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;
/**

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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'
);

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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 = '';

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,
]
],
]
: [];
}

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
));
}

View File

@@ -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;

View File

@@ -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';
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
/**

View File

@@ -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']);
});
}

View File

@@ -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
*

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View 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;
}
}

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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],
]);
}
}

View File

@@ -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;

View File

@@ -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);
}
/**

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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(

Some files were not shown because too many files have changed in this diff Show More