Skip to content

Commit 9b4f73e

Browse files
authored
Merge pull request #102 from dotkernel/issue-99
Issue #99: Remove PHP 8.1 and add PHP 8.4 & 8.5 support
2 parents 835480e + 3878745 commit 9b4f73e

24 files changed

+183
-131
lines changed

.github/workflows/codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- "8.2"
1919
- "8.3"
2020
- "8.4"
21+
- "8.5"
2122

2223
steps:
2324
- name: Checkout
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
- push
3+
4+
name: Run PHPStan checks
5+
6+
jobs:
7+
mutation:
8+
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.2"
19+
- "8.3"
20+
- "8.4"
21+
- "8.5"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: "${{ matrix.php }}"
31+
coverage: pcov
32+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
33+
tools: composer:v2, cs2pr
34+
35+
- name: Determine composer cache directory
36+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
37+
38+
- name: Cache dependencies installed with composer
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ env.COMPOSER_CACHE_DIR }}
42+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
43+
restore-keys: |
44+
php${{ matrix.php }}-composer-
45+
46+
- name: Install dependencies with composer
47+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
48+
49+
- name: Run static analysis with PHPStan
50+
run: vendor/bin/phpstan analyse

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# dot-mail
22

3-
> [!IMPORTANT]
43
> dot-mail is a wrapper on top of [symfony mailer](https://github.com/symfony/mailer)
54
65
## dot-mail badges
76

87
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-mail)
9-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-mail/5.2.1)
8+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-mail/5.0.4)
109

1110
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-mail)](https://github.com/dotkernel/dot-mail/issues)
1211
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-mail)](https://github.com/dotkernel/dot-mail/network)
@@ -15,6 +14,7 @@
1514

1615
[![Build Static](https://github.com/dotkernel/dot-mail/actions/workflows/continuous-integration.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/dot-mail/actions/workflows/continuous-integration.yml)
1716
[![codecov](https://codecov.io/gh/dotkernel/dot-mail/branch/5.0/graph/badge.svg?token=G51NEHYKD3)](https://codecov.io/gh/dotkernel/dot-mail)
17+
[![PHPStan](https://github.com/dotkernel/dot-mail/actions/workflows/static-analysis.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/dot-mail/actions/workflows/static-analysis.yml)
1818

1919
## Installation
2020

@@ -28,10 +28,9 @@ composer require dotkernel/dot-mail
2828

2929
### Mail - Sendmail
3030

31-
If your server has Sendmail installed, update the `config/autoload/mail.local.php.dist` file by setting the `transport` key like below
31+
If your server has Sendmail installed, update the `config/autoload/mail.local.php.dist` file by setting the `transport` key like below:
3232

3333
```php
34-
<?php
3534
return [
3635
'dot_mail' => [
3736
'default' => [
@@ -40,12 +39,13 @@ return [
4039
//...
4140
]
4241
]
43-
]
42+
];
4443
```
4544

4645
### Mail - ESMTP
4746

48-
If you want your application to send mails on e.g. registration, contact, then edit the file `config/autoload/mail.local.php`. Set the `transport`, `message_options` and `smtp_options` keys like below.
47+
If you want your application to send mails on e.g., registration, contact, then edit the file `config/autoload/mail.local.php`.
48+
Set the `transport`, `message_options` and `smtp_options` keys like below.
4949

5050
Under `message_options` key:
5151

@@ -56,12 +56,11 @@ Under `smtp_options` key:
5656
- `host` - the mail server's hostname or IP address
5757
- `port` - the mail server's port
5858
- `connection_config` - fill in the `username` and `password` keys with the login details of the email used in `from` above
59-
- if you want to disable auto_tls set `tls` key to false
59+
- if you want to disable `auto_tls` set `tls` key to false
6060

61-
> Note: all other keys can be left as is.
61+
> All other keys can be left as is.
6262
6363
```php
64-
<?php
6564
return [
6665
'dot_mail' => [
6766
'default' => [
@@ -83,22 +82,25 @@ return [
8382
//...
8483
]
8584
]
86-
]
85+
];
8786
```
8887

89-
In `config/autoload/local.php` add under `contact` => `message_receivers` => `to` key *string* values with the emails that should receive contact messages
88+
In `config/autoload/local.php` add under `contact` => `message_receivers` => `to` key *string* values with the emails that should receive contact messages.
9089

91-
> Note: **Please add at least 1 email address in order for contact message to reach someone**
90+
> **Please add at least one email address in order for a contact message to reach someone**
9291
93-
Also feel free to add as many cc as you want under `contact` => `message_receivers` => `cc` key
92+
Also feel free to add as many cc as you want under `contact` => `message_receivers` => `cc` key.
9493

9594
### Sending an e-mail
9695

97-
Below is an example of how to use the email in the most basic way. You can add your own code to it e.g. to get the user data from a User object or from a config file, to use a template for the body.
96+
Below is an example of how to use the email in the most basic way.
97+
You can add your own code to it, e.g., to get the user data from a User object or from a config file, to use a template for the body.
9898

99-
Note that `addTo` is only one of the methods available for the `Message` class returned by `getMessage()`. Other useful methods that were not included in the example are `addCc()`, `addBcc()`, `addReplyTo()`.
99+
Note that `addTo` is only one of the methods available for the `Message` class returned by `getMessage()`.
100+
Other useful methods that were not included in the example are `addCc()`, `addBcc()`, `addReplyTo()`.
100101

101-
The returned type is boolean, but if the `isValid()` method is removed, the returned type becomes `MailResult` which allows the use of `getMessage()` for a more detailed error message. See the `Testing if an e-mail message is valid` section below.
102+
The returned type is boolean, but if the `isValid()` method is removed, the returned type becomes `MailResult` which allows the use of `getMessage()` for a more detailed error message.
103+
See the `Testing if an e-mail message is valid` section below.
102104

103105
```php
104106
public function sendBasicMail()
@@ -111,7 +113,8 @@ public function sendBasicMail()
111113
}
112114
```
113115

114-
It's optional, but recommended to call the above function in a `try-catch` block to display helpful error messages. The next example calls the `sendBasicMail` function from within `UserController`, but you can implement it in other controllers, just make sure that the controller's construct also includes the `FlashMessenger` parameter `$messenger`.
116+
It's optional but recommended to call the above function in a `try-catch` block to display helpful error messages.
117+
The next example calls the `sendBasicMail` function from within `UserController`, but you can implement it in other controllers, just make sure that the controller's construct also includes the `FlashMessenger` parameter `$messenger`.
115118

116119
```php
117120
try {
@@ -126,7 +129,7 @@ try {
126129

127130
### Testing if an e-mail message is valid
128131

129-
After sending an e-mail you can check if the message was valid or not.
132+
After sending an e-mail, you can check if the message was valid or not.
130133
The `$this->mailService->send()->isValid()` method call will return a boolean value.
131134
If the returned result is `true`, the e-mail was valid, otherwise the e-mail was invalid.
132135
In case your e-mail was invalid, you can check for any errors using `$this->mailService->send()->getMessage()`.
@@ -146,19 +149,18 @@ if (! $result->isValid()) {
146149
147150
### Logging outgoing emails
148151

149-
Optionally, you can keep a log of each successfully sent email. This might be useful when you need to know if/when a specific email has been sent out to a recipient.
152+
Optionally, you can keep a log of each successfully sent email.
153+
This might be useful when you need to know if/when a specific email has been sent out to a recipient.
150154

151155
Logs are stored in the following format:
152156

153157
```text
154158
[YYYY-MM-DD HH:MM:SS]: {"subject":"Test subject","to":["Test Account <test@dotkernel.com>"],"cc":[],"bcc":[]}.
155159
```
156160

157-
In order to enable it, make sure that your `config/autoload/mail.local.php` has the below `log` configuration under the `dot_mail` key:
161+
To enable it, make sure that your `config/autoload/mail.local.php` has the below `log` configuration under the `dot_mail` key:
158162

159163
```php
160-
<?php
161-
162164
return [
163165
'dot_mail' => [
164166
...

SECURITY.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,29 @@
22

33
## Supported Versions
44

5-
65
| Version | Supported | PHP Version |
76
|---------|--------------------|----------------------------------------------------------------------------------------------------------|
8-
| 5.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-mail/5.0.0) |
7+
| 5.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-mail/5.0.4) |
98
| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-mail/4.3.0) |
109
| <= 3.x | :x: | |
1110

12-
1311
## Reporting Potential Security Issues
1412

15-
If you have encountered a potential security vulnerability in this project,
16-
please report it to us at <security@dotkernel.com>. We will work with you to
17-
verify the vulnerability and patch it.
13+
If you have encountered a potential security vulnerability in this project, please report it to us at <security@dotkernel.com>.
14+
We will work with you to verify the vulnerability and patch it.
1815

1916
When reporting issues, please provide the following information:
2017

2118
- Component(s) affected
2219
- A description indicating how to reproduce the issue
2320
- A summary of the security vulnerability and impact
2421

25-
We request that you contact us via the email address above and give the
26-
project contributors a chance to resolve the vulnerability and issue a new
27-
release prior to any public exposure; this helps protect the project's
28-
users, and provides them with a chance to upgrade and/or update in order to
29-
protect their applications.
30-
22+
We request that you contact us via the email address above and give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure;
23+
this helps protect the project's users and provides them with a chance to upgrade and/or update to protect their applications.
3124

3225
## Policy
3326

3427
If we verify a reported security vulnerability, our policy is:
3528

36-
- We will patch the current release branch, as well as the immediate prior minor
37-
release branch.
38-
39-
- After patching the release branches, we will immediately issue new security
40-
fix releases for each patched release branch.
29+
- We will patch the current release branch, as well as the immediate prior minor release branch.
30+
- After patching the release branches, we will immediately issue new security fix releases for each patched release branch.

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
},
2929
"require": {
30-
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
30+
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
3131
"ext-fileinfo": "*",
3232
"ext-json": "*",
3333
"dotkernel/dot-event": "^4.0",
@@ -37,8 +37,9 @@
3737
"require-dev": {
3838
"laminas/laminas-coding-standard": "^3.0",
3939
"mikey179/vfsstream": "^v1.6.11",
40-
"phpunit/phpunit": "^10.5",
41-
"vimeo/psalm": "^6.0"
40+
"phpstan/phpstan": "^2.1.17",
41+
"phpstan/phpstan-phpunit": "^2.0.6",
42+
"phpunit/phpunit": "^10.5"
4243
},
4344
"autoload": {
4445
"psr-4": {
@@ -58,8 +59,7 @@
5859
],
5960
"cs-check": "phpcs",
6061
"cs-fix": "phpcbf",
61-
"test": "phpunit --colors=always",
62-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
63-
"static-analysis": "psalm --shepherd --stats"
62+
"static-analysis": "phpstan analyse --memory-limit 1G",
63+
"test": "phpunit --colors=always"
6464
}
6565
}

docs/book/v4/configuration.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ Using `Laminas\Mail\Transport\File` as the transport will require uncommenting t
5050
## Logging configuration
5151

5252
Uncommenting the `dot-mail.log` key will save a copy of all sent emails' subject, recipient addresses, cc and bcc addresses alongside a timestamp.
53-
In order to enable it, make sure that your `mail.local.php` has the below `log` configuration under the `dot_mail` key:
53+
To enable it, make sure that your `mail.local.php` has the below `log` configuration under the `dot_mail` key:
5454

5555
```php
56-
<?php
57-
5856
return [
5957
'dot_mail' => [
6058
...

docs/book/v4/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
55
## Extra features
66

7-
- the option to log the results of the mailing process it provides the developer with more information and greater control.
7+
The option to log the results of the mailing process it provides the developer with more information and greater control.

docs/book/v4/transports.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@
99

1010
> Feel free to use any custom transport you desire, provided it implements the mentioned `TransportInterface`.
1111
12-
`Sendmail` is a wrapper over PHP's `mail()` function, and as such has a different behaviour on Windows than on *nix systems. Using sendmail on Windows **will not work in combination with** `addBcc()`.
12+
`Sendmail` is a wrapper over PHP's `mail()` function, and as such has a different behavior on Windows than on *nix systems. Using sendmail on Windows **will not work in combination with** `addBcc()`.
1313

1414
- Note: emails sent using the sendmail transport will be more often delivered to SPAM.
1515

16-
`Smtp` connects to the configured SMTP host in order to handle sending emails. Saving a copy of an outgoing mail into a folder is possible for this transport only, and is done by uncommenting `save_sent_message_folder` in the config file `mail.local.php` under `dot_mail.default`.
16+
`Smtp` connects to the configured SMTP host to handle sending emails.
17+
Saving a copy of outgoing mail into a folder is possible for this transport only, and is done by uncommenting `save_sent_message_folder` in the config file `mail.local.php` under `dot_mail.default`.
1718

18-
- Common folder names are `INBOX`, `INBOX.Archive`, `INBOX.Drafts`, `INBOX.Sent`, `INBOX.Spam`, `INBOX.Trash`. If you have `MailService` available in your class, you can call `$this->mailService->getFolderGlobalNames()` to list the folder global names for the email you are using.
19+
- Common folder names are `INBOX`, `INBOX.Archive`, `INBOX.Drafts`, `INBOX.Sent`, `INBOX.Spam`, `INBOX.Trash`.
20+
If you have `MailService` available in your class, you can call `$this->mailService->getFolderGlobalNames()` to list the folder global names for the email you are using.
1921
- Multiple folders can be added to the `save_sent_message_folder` key to save a copy of the outgoing email in each folder.
2022

21-
`File` writes each message individually in a file named after the configured format, placed in the configured directory. From here the files may be used for sending via another transport mechanism, or simply as logs.
23+
`File` writes each message individually in a file named after the configured format, placed in the configured directory.
24+
From here the files may be used for sending via another transport mechanism, or simply as logs.
2225

2326
`InMemory` saves the message in memory, allowing access to the last "sent" message via the `getLastMessage()` function.
2427

25-
- As the email is not sent, this transport can be helpful in development, with the access to the message being potentially useful in tests as well
28+
- As the email is not sent, this transport can be helpful in development, with the access to the message being potentially useful in tests as well.
2629

2730
```php
2831
$this->mailService->setBody('First email body');

docs/book/v4/usage.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
## Sending an e-mail
44

5-
Below is an example of how to use the email in the most basic way. You can add your own code to it e.g. to get the user data from a User object or from a config file, to use a template for the body.
5+
Below is an example of how to use the email in the most basic way. You can add your own code to it, e.g., to get the user data from a User object or from a config file, to use a template for the body.
66

7-
Note that `addTo` is only one of the methods available for the `Message` class returned by `getMessage()`. Other useful methods that were not included in the example are `addCc()`, `addBcc()`, `addReplyTo()`.
7+
Note that `addTo` is only one of the methods available for the `Message` class returned by `getMessage()`.
8+
Other useful methods that were not included in the example are `addCc()`, `addBcc()`, `addReplyTo()`.
89

9-
The returned type is boolean, but if the `isValid()` method is removed, the returned type becomes `MailResult` which allows the use of `getMessage()` for a more detailed error message. See the `Testing if an e-mail message is valid` section below.
10+
The returned type is boolean, but if the `isValid()` method is removed, the returned type becomes `MailResult` which allows the use of `getMessage()` for a more detailed error message.
11+
See the `Testing if an e-mail message is valid` section below.
1012

1113
```php
1214
public function sendBasicMail()
@@ -19,7 +21,8 @@ public function sendBasicMail()
1921
}
2022
```
2123

22-
It's optional, but recommended to call the above function in a `try-catch` block to display helpful error messages. The next example calls the `sendBasicMail` function from within `UserController`, but you can implement it in other controllers, just make sure that the controller's construct also includes the `FlashMessenger` parameter `$messenger`.
24+
It's optional but recommended to call the above function in a `try-catch` block to display helpful error messages.
25+
The next example calls the `sendBasicMail` function from within `UserController`, but you can implement it in other controllers, just make sure that the controller's construct also includes the `FlashMessenger` parameter `$messenger`.
2326

2427
```php
2528
try {
@@ -34,7 +37,7 @@ try {
3437

3538
## Testing if an e-mail message is valid
3639

37-
After sending an e-mail you can check if the message was valid or not.
40+
After sending an e-mail, you can check if the message was valid or not.
3841
The `$this->mailService->send()->isValid()` method call will return a boolean value.
3942
If the returned result is `true`, the e-mail was valid, otherwise the e-mail was invalid.
4043
In case your e-mail was invalid, you can check for any errors using `$this->mailService->send()->getMessage()`.

docs/book/v5/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Sending email with the `esmtp` transport requires valid data for the values unde
3131
## Logging configuration
3232

3333
Uncommenting the `dot-mail.log` key will save a copy of all sent emails' subject, recipient addresses, cc and bcc addresses alongside a timestamp.
34-
In order to enable it, make sure that your `mail.local.php` has the below `log` configuration under the `dot_mail` key:
34+
To enable it, make sure that your `mail.local.php` has the below `log` configuration under the `dot_mail` key:
3535

3636
```php
3737
<?php

0 commit comments

Comments
 (0)