Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message::buildText(): Trim each text line. #84

Merged
merged 15 commits into from Jun 2, 2021
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/Bug_report.md

This file was deleted.

9 changes: 0 additions & 9 deletions .github/ISSUE_TEMPLATE/Feature_request.md

This file was deleted.

12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE/Support_question.md

This file was deleted.

21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/Support_us.md

This file was deleted.

2 changes: 0 additions & 2 deletions .github/funding.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/pull_request_template.md

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/coding-style.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v1
with:
php-version: 7.1
php-version: 8.0
coverage: none

- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v1
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v1
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
php: ['8.0']

fail-fast: false

Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.1
php-version: 8.0
coverage: none

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
Expand All @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -15,14 +15,14 @@
}
],
"require": {
"php": ">=7.1 <8.1",
"php": ">=8.0 <8.1",
"ext-iconv": "*",
"nette/utils": "^3.1"
"nette/utils": "^3.2.1 || ^4.0"
},
"require-dev": {
"nette/di": "^3.0.0",
"nette/tester": "^2.0",
"tracy/tracy": "^2.4",
"nette/di": "^4.0",
"nette/tester": "^2.4",
"tracy/tracy": "^2.8",
"phpstan/phpstan-nette": "^0.12"
},
"conflict": {
Expand All @@ -42,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "4.0-dev"
}
}
}
33 changes: 0 additions & 33 deletions contributing.md

This file was deleted.

2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -33,7 +33,7 @@ Installation
composer require nette/mail
```

It requires PHP version 7.1 and supports PHP up to 8.0.
It requires PHP version 8.0.


Creating Emails
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/MailDI/MailExtension.php
Expand Up @@ -39,7 +39,7 @@ public function getConfigSchema(): Nette\Schema\Schema
'privateKey' => Expect::string()->required(),
'passPhrase' => Expect::string()->dynamic(),
'testMode' => Expect::bool(false)->dynamic(),
])->castTo('array')
])->castTo('array'),
),
])->castTo('array');
}
Expand Down
29 changes: 8 additions & 21 deletions src/Mail/DkimSigner.php
Expand Up @@ -28,20 +28,15 @@ class DkimSigner implements Signer

private const DKIM_SIGNATURE = 'DKIM-Signature';

/** @var string */
private $domain;
private string $domain;

/** @var array */
private $signHeaders;
private array $signHeaders;

/** @var string */
private $selector;
private string $selector;

/** @var string */
private $privateKey;
private string $privateKey;

/** @var string */
private $passPhrase;
private string $passPhrase;


/** @throws Nette\NotSupportedException */
Expand Down Expand Up @@ -133,14 +128,8 @@ protected function sign(string $value): string
}

if (openssl_sign($value, $signature, $privateKey, 'sha256WithRSAEncryption')) {
if (PHP_VERSION_ID < 80000) {
openssl_pkey_free($privateKey);
}
return base64_encode($signature);
}
if (PHP_VERSION_ID < 80000) {
openssl_pkey_free($privateKey);
}
return '';
}

Expand All @@ -150,8 +139,8 @@ protected function computeBodyHash(string $body): string
return base64_encode(
pack(
'H*',
hash('sha256', $body)
)
hash('sha256', $body),
),
);
}

Expand All @@ -166,9 +155,7 @@ protected function normalizeNewLines(string $s): string

protected function getSignedHeaders(Message $message): array
{
return array_filter($this->signHeaders, function ($name) use ($message) {
return $message->getHeader($name) !== null;
});
return array_filter($this->signHeaders, fn($name) => $message->getHeader($name) !== null);
}


Expand Down
17 changes: 7 additions & 10 deletions src/Mail/FallbackMailer.php
Expand Up @@ -17,21 +17,19 @@ class FallbackMailer implements Mailer
use Nette\SmartObject;

/** @var callable[] function (FallbackMailer $sender, SendException $e, Mailer $mailer, Message $mail): void */
public $onFailure;
public array $onFailure = [];

/** @var Mailer[] */
private $mailers;
private array $mailers;

/** @var int */
private $retryCount;
private int $retryCount;

/** @var int in miliseconds */
private $retryWaitTime;
/** in miliseconds */
private int $retryWaitTime;


/**
* @param Mailer[] $mailers
* @param int $retryWaitTime in miliseconds
*/
public function __construct(array $mailers, int $retryCount = 3, int $retryWaitTime = 1000)
{
Expand Down Expand Up @@ -64,7 +62,7 @@ public function send(Message $mail): void

} catch (SendException $e) {
$failures[] = $e;
$this->onFailure($this, $e, $mailer, $mail);
Nette\Utils\Arrays::invoke($this->onFailure, $this, $e, $mailer, $mail);
}
}
}
Expand All @@ -75,8 +73,7 @@ public function send(Message $mail): void
}


/** @return static */
public function addMailer(Mailer $mailer)
public function addMailer(Mailer $mailer): static
{
$this->mailers[] = $mailer;
return $this;
Expand Down