https://github.com/hostbrook/laravel-dkim
Sign all outgoing emails in Laravel 9.x with a DKIM signature.
https://github.com/hostbrook/laravel-dkim
dkim dkim-signature laravel
Last synced: about 1 month ago
JSON representation
Sign all outgoing emails in Laravel 9.x with a DKIM signature.
- Host: GitHub
- URL: https://github.com/hostbrook/laravel-dkim
- Owner: hostbrook
- License: mit
- Created: 2021-07-08T22:16:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-17T13:25:43.000Z (10 months ago)
- Last Synced: 2025-10-23T03:42:34.266Z (3 months ago)
- Topics: dkim, dkim-signature, laravel
- Language: PHP
- Homepage: https://github.com/hostbrook/laravel-dkim
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel 9.x, 10.x, 11.x and 12.x DKIM signature
Sign all outgoing emails in Laravel 9.x, 10.x, 11.x and 12.x with a DKIM signature.
> **IMPORTANT!** The package version that supports Laravel 10.x starts from 1.2.5
> **IMPORTANT!** The package version that supports Laravel 11.x starts from 1.4
> **IMPORTANT!** The package version that supports Laravel 12.x starts from 1.5
## Installation and setup
1. Get the latest version of the package via Composer:
```
composer require hostbrook/laravel-dkim
```
2. In `config/app.php` comment the line with the original mail service provider (if exists) and add the line with the new mail service provider:
```
// Illuminate\Mail\MailServiceProvider::class,
HostBrook\LaravelDkim\DkimMailServiceProvider::class,
```
3. Add your DKIM private key settings in `/.env` or in `/config/mail.php`. The priority of DKIM settings is from `/.env` file.
3.1. The syntax, if you want to add DKIM private key settings in `/.env` file:
```
DKIM_SELECTOR="selector1"
DKIM_DOMAIN="domain.name"
DKIM_PASSPHRASE=""
DKIM_PRIVATE_KEY="/storage/app/dkim/private_key.txt"
```
As an option, you can add the full RSA Private Key to the `.env` file, for example:
```
DKIM_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAq1SCAScet736Rr/f36OYUo8cRziq4v2uq6kNs5wzEaaqUAoh
...
ENwDlqtgpM9D7YznrL6W9NH7fdSwmz2Ux0frY6weuBx/VSeJn1fb
-----END RSA PRIVATE KEY-----"
```
3.2. The syntax, if you want to add DKIM private key settings in `/config/mail.php` file:
```
'dkim_selector' => 'selector1',
'dkim_domain' => 'domain.name',
'dkim_passphrase' => '', // leave empty if you didn’t protect the private key
'dkim_private_key' => '/storage/app/dkim/private_key.txt',
```
As an option, you can add the full RSA Private Key to the `/config/mail.php` file, for example:
```
'dkim_private_key' => '-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAq1SCAScet736Rr/f36OYUo8cRziq4v2uq6kNs5wzEaaqUAoh
...
ENwDlqtgpM9D7YznrL6W9NH7fdSwmz2Ux0frY6weuBx/VSeJn1fb
-----END RSA PRIVATE KEY-----',
```
## Notes and recommendations
- No matter where you keep the RSA Private Key, in `/.env` file or in `/config/mail.php` file or in a text file, everything between two instances `'-----BEGIN RSA PRIVATE KEY-----'` and `'-----END RSA PRIVATE KEY-----'` must be right up to the start of the line!
- It is not recommended to keep private key directly in the `/config/mail.php` file for security reasons especially if your project is not in the private repository.
- If you would like to keep RSA Private key in a text file, the path to the text file must be relative to the project base path (like in the example above).
## Upgrading
Whenever there is a new release, then from the command line in your **_project root_**:
```shell
composer update
```
## Deleting package
Running the following command will remove the package from vendor folder:
```shell
composer remove hostbrook/laravel-dkim
```
## DKIM info
Read more how to:
- [Generate DKIM Public and Private Keys](https://tools.socketlabs.com/dkim/generator)
- [Check if DKIM record is shown and has a correct format](https://dmarcly.com/tools/dkim-record-checker)
- [Test the Spammyness of your Emails](https://www.mail-tester.com)
## References
- [DUDU54/laravel-dkim](https://github.com/DUDU54/laravel-dkim)
- [simonschaufi/laravel-dkim](https://github.com/simonschaufi/laravel-dkim)