PHPackages                             jv-conseil/dkim-php-mail-signature - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. jv-conseil/dkim-php-mail-signature

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

jv-conseil/dkim-php-mail-signature
==================================

🔏 Stand-alone DKIM class to sign your emails with a 2048 bit private key hashed with SHA-256 algorithm.

v1.2.6(3y ago)31.3k↓25%1[1 issues](https://github.com/JV-conseil-Internet-Consulting/dkim-php-mail-signature/issues)EUPL-1.2PHPPHP &gt;=5.6.37

Since Nov 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/JV-conseil-Internet-Consulting/dkim-php-mail-signature)[ Packagist](https://packagist.org/packages/jv-conseil/dkim-php-mail-signature)[ Docs](http://www.jv-conseil.net)[ GitHub Sponsors](https://github.com/JV-conseil)[ RSS](/packages/jv-conseil-dkim-php-mail-signature/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (9)Used By (0)

DkimPhpMailSignature
====================

[](#dkimphpmailsignature)

[![Packagist Version](https://camo.githubusercontent.com/61aad43dc8588cf0c5d733c76fe25ab51ddc755d944ded9a46edba23d88e4f10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a762d636f6e7365696c2f646b696d2d7068702d6d61696c2d7369676e61747572653f636f6c6f723d6f72616e6765)](https://packagist.org/packages/jv-conseil/dkim-php-mail-signature)[![Packagist Dependency Version](https://camo.githubusercontent.com/89283cbb3c793a8618cca019e7ed8aacae8e7ddc09343fd7ccb25a7e88542713/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a762d636f6e7365696c2f646b696d2d7068702d6d61696c2d7369676e61747572652f706870)](https://packagist.org/packages/jv-conseil/dkim-php-mail-signature)[![visitors](https://camo.githubusercontent.com/581160fb5a3e48399d4981140da198b2004ebdf2b225dca449b92977de63f4ce/68747470733a2f2f76697369746f722d62616467652e6c616f62692e6963752f62616467653f706167655f69643d4a562d636f6e7365696c2d496e7465726e65742d436f6e73756c74696e672e646b696d2d7068702d6d61696c2d7369676e6174757265)](https://camo.githubusercontent.com/581160fb5a3e48399d4981140da198b2004ebdf2b225dca449b92977de63f4ce/68747470733a2f2f76697369746f722d62616467652e6c616f62692e6963752f62616467653f706167655f69643d4a562d636f6e7365696c2d496e7465726e65742d436f6e73756c74696e672e646b696d2d7068702d6d61696c2d7369676e6174757265)[![License EUPL 1.2](https://camo.githubusercontent.com/3b7871a41ea959dc3dcb73b77db0dd13b838353d6ffc04e3b2ecd170f15e4212/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4555504c2d2d312e322d626c75652e737667)](LICENSE)[![Become a sponsor to JV-conseil](https://camo.githubusercontent.com/d2432db86e1cfca636933728a664bf886cff501efab549a0af6abab26fe8851b/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d53706f6e736f72266d6573736167653d254532253944254134266c6f676f3d47697448756226636f6c6f723d253233666538653836)](https://github.com/sponsors/JV-conseil "Become a sponsor to JV-conseil")[![Follow JV conseil on StackOverflow](https://camo.githubusercontent.com/de65d938fc35d0af577361f9008407a46ea5380948db1ce8107be38f1db6b5e2/68747470733a2f2f696d672e736869656c64732e696f2f737461636b65786368616e67652f737461636b6f766572666c6f772f722f32343737383534)](https://stackoverflow.com/users/2477854/jv-conseil "Follow JV conseil on StackOverflow")[![Follow JVconseil on Twitter](https://camo.githubusercontent.com/598cfffb5240a8e1d03a3deaf99443f9704e4d9d864722e18146fe825e884b60/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f4a56636f6e7365696c2e7376673f7374796c653d736f6369616c266c6f676f3d74776974746572)](https://twitter.com/JVconseil "Follow JVconseil on Twitter")[![Follow JVconseil on Mastodon](https://camo.githubusercontent.com/757ebd07cda63d607038a5e78aea73716a1a2f87cab1c4fe38b169e1f26a8fb4/68747470733a2f2f696d672e736869656c64732e696f2f6d6173746f646f6e2f666f6c6c6f772f313130393530313232303436363932343035)](https://mastodon.social/@JVconseil "Follow JVconseil@mastodon.social on Mastodon")[![Follow JV conseil on GitHub](https://camo.githubusercontent.com/996ade5dcaa1380e35ea4edfa9264b95207d197cd72ef66d0101298d2652241e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f6c6c6f776572732f4a562d636f6e7365696c3f6c6162656c3d4a562d636f6e7365696c267374796c653d736f6369616c)](https://github.com/JV-conseil "Follow JV-conseil on GitHub")

> 🔏 Stand-alone DKIM class to sign your emails with a 2048 bit private key hashed with SHA-256 algorithm.

[![DkimPhpMailSignature](https://user-images.githubusercontent.com/8126807/69017623-83495b80-09a8-11ea-8eee-757594d4e6ab.png)](https://user-images.githubusercontent.com/8126807/69017623-83495b80-09a8-11ea-8eee-757594d4e6ab.png)

Usage
-----

[](#usage)

Sample lines to import into your mail code to start signing with DKIM:

```
require_once __DIR__ . '/../vendor/autoload.php' ; // Autoload files using Composer autoload
use JVconseil\DkimPhpMailSignature\DKIMsign ;
use JVconseil\DkimPhpMailSignature\DKIMconfig ;

// init
$config = new DKIMconfig('/www/inc/config/jv-conseil/dkim-php-mail-signature/config.inc.php') ;
$sign = new DKIMsign(
 $config->private_key,
 $config->passphrase,
 $config->domain,
 $config->selector
) ;

// sign
$signed_headers = $sign->get_signed_headers($to, $subject, $message, $headers) ;

// send email
mail($to, $subject, $message, $signed_headers.$headers) ;
```

Installation
------------

[](#installation)

> Step by Step guide to generate your encryption keys and populate them through your DNS records.

Installation &amp; loading
--------------------------

[](#installation--loading)

DkimPhpMailSignature is available on [Packagist](https://packagist.org/packages/jv-conseil/dkim-php-mail-signature) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install DkimPhpMailSignature. Just add this line to your `composer.json` file:

```
"jv-conseil/dkim-php-mail-signature": "^1.0"
```

or run

```
composer require jv-conseil/dkim-php-mail-signature
```

Note that the `vendor` folder and the `vendor/autoload.php` script are generated by Composer; they are not part of DkimPhpMailSignature.

Make your own copy of config file
---------------------------------

[](#make-your-own-copy-of-config-file)

Before starting you should make a copy of folder `config/` and store it outside your `vendor/` Composer repository in a non-public area of your website e.g.:

```
/www/inc/config/jv-conseil/dkim-php-mail-signature/
```

Failing to do so will expose you to lose all your settings in case of a future Composer udpate.

Generate your Public &amp; Private Encryption keys
--------------------------------------------------

[](#generate-your-public--private-encryption-keys)

In Terminal enter this command line to start working under the path of your `config/` folder:

```
cd /www/inc/config/jv-conseil/dkim-php-mail-signature/
```

In Terminal enter this command line to generate a new **private 2048 bit encryption key**:

```
openssl genrsa -des3 -out private.pem 2048
```

Enter your **Pass Phrase** and save it for editing your `config.inc.php` file in the next step.

Then retrieve your **public key**:

```
openssl rsa -in private.pem -out public.pem -outform PEM -pubout
```

*You can delete the two originals `*.pem` file keys stored in the `config/` folder if they create a conflict in the creation process of your keys.*

Edit your DNS with a new DKIM record
------------------------------------

[](#edit-your-dns-with-a-new-dkim-record)

Access your registrar interface (e.g.: OVH.com) and create a new **DKIM record** to declare your **public key**:

```
selector._domainkey  IN TXT  ( "v=DKIM1;k=rsa;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ekggNf9vuzzL4SlVc8QZyyqbEwR5bVTPC9cEZ8hFqTKOc7go180n3RZilYJZvveaxBkLCVJSTQaMPtKuSptY5au6Pi3AkFlizzhUJ80+0zgZXSGx7gfbginbRwhD+XdGOe9NXpo0PfrD6dEJ49Ytx4/nHB0TKiL227C0kGWb7RfWTVWccgJq4+kQb4l+4" "oDU5rGomSYK+zmMV13QTSETcJnoXhmjoJ30omyJfEXAsK5Ny0LJo8rWCucLD31BxHrM9/+M/Ye+TWxcrD2mRh5Jxqcnyj00/7kCnWeGPTftVKkAJBP3JMRqCNShLUchLhaz0qeXUtxAe9dx7ltr8042QIDAQAB;" )
```

DKIM works better with **SPF** and **DMARC** records, you should consider editing them too:

```
3600     IN TXT  "v=spf1 include:_spf.google.com ~all"
_dmarc   IN TXT  "v=DMARC1; p=quarantine; rua=mailto:me@yourdomain.name"
```

Further reading:

- [Add DKIM domain key to domain DNS records](https://support.google.com/a/answer/173535)
- [Manage suspicious emails with DMARC](https://support.google.com/a/answer/2466563?hl=en)
- [Help prevent email spoofing with SPF records](https://support.google.com/a/answer/33786?hl=en)

Edit your Config File
---------------------

[](#edit-your-config-file)

Under `config/config.sample.inc.php` you will find a config file example to help you set your own details.

Now you can drop `.sample` in the filename and start editing it:

- **domain**: your domain name e.g: google.com
- **selector**: `selector` used in your DKIM DNS record, e.g.: selector.\_domainkey.MAIL\_DKIM\_DOMAIN
- **passphrase**: your pass phrase used to generate your keys e.g.: myPassPhrase.
- ... other parameters can be omitted.

Simple Use
----------

[](#simple-use)

Sample lines to import into your mail code to start signing with DKIM:

```
require_once __DIR__ . '/../vendor/autoload.php' ; // Autoload files using Composer autoload
use JVconseil\DkimPhpMailSignature\DKIMsign ;
use JVconseil\DkimPhpMailSignature\DKIMconfig ;

// init
$config = new DKIMconfig('/www/inc/config/jv-conseil/dkim-php-mail-signature/config.inc.php') ;

// set: this calls __set()
$config->domain = "mynewdomain.name" ;

// get: this calls __get()
$config->domain ; // => "mynewdomain.name" ;
```

Introducing DKIMmail class
--------------------------

[](#introducing-dkimmail-class)

> 📬 Stand-alone class to send DKIM signed emails with a 2048 bit private key hashed with SHA-256 algorithm.

```
// init
$mail = new DKIMmail('/www/inc/config/jv-conseil/dkim-php-mail-signature/config.inc.php') ;

// parameters
$mail->from    = "Sender"  ;
$mail->to      = "Recipient"  ;
$mail->subject = "Your Mail Subject" ;
$mail->body    = "Your Mail Message." ;
$mail->attach("/path/to/your/attachment.jpg", "NameOfYourAttachment.jpg") ;

// send!
$mail->send() ;
```

Documentation
-------------

[](#documentation)

Documentation is [available online](https://jv-conseil-internet-consulting.github.io/dkim-php-mail-signature/classes/JVconseil.DkimPhpMailSignature.DKIMconfig.html), though it may not be quite up to date or match your version exactly.

You can generate API documentation by running `phpdoc` in the top-level folder of this project, and documentation will be generated in this folder:

```
php ~/vendor/bin/phpdoc -d ~/dkim-php-mail-signature/ -t ~/dkim-php-mail-signature/docs/
```

You will need to have [phpDocumentor](https://www.phpdoc.org) installed.

Sponsorship
-----------

[](#sponsorship)

If this project helps you reduce time to develop, you can give me a cup of coffee ☕️ :-)

[![Become a sponsor to JV-conseil](https://camo.githubusercontent.com/d2432db86e1cfca636933728a664bf886cff501efab549a0af6abab26fe8851b/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d53706f6e736f72266d6573736167653d254532253944254134266c6f676f3d47697448756226636f6c6f723d253233666538653836)](https://github.com/sponsors/JV-conseil)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~175 days

Recently: every ~306 days

Total

8

Last Release

1142d ago

PHP version history (2 changes)v1.0.4PHP &gt;=7.1

v1.2.0PHP &gt;=5.6.37

### Community

Maintainers

![](https://www.gravatar.com/avatar/674e06292e01f38e58fe83747b26a76be63e7365f792670dd9da8315c68f222d?d=identicon)[JV-conseil](/maintainers/JV-conseil)

---

Top Contributors

[![JV-conseil](https://avatars.githubusercontent.com/u/8126807?v=4)](https://github.com/JV-conseil "JV-conseil (61 commits)")

---

Tags

composerdkimdkim-recorddkim-signaturedmarcdmarc-recorddns-recordsemailencryption-keyspackagistphpphp5-6spfspf-recordphpcomposerpackagistspfdmarcdkimdkim-signaturedmarc-recordspf-record

### Embed Badge

![Health badge](/badges/jv-conseil-dkim-php-mail-signature/health.svg)

```
[![Health](https://phpackages.com/badges/jv-conseil-dkim-php-mail-signature/health.svg)](https://phpackages.com/packages/jv-conseil-dkim-php-mail-signature)
```

###  Alternatives

[tomatophp/filament-accounts

Manage your multi accounts inside your app using 1 table with multi auth and a lot of integrations

748.3k7](/packages/tomatophp-filament-accounts)[djunehor/laravel-sms

Send SMS from your laravel application

385.3k1](/packages/djunehor-laravel-sms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
