Skip to content

Installation

JV conseil edited this page Nov 19, 2019 · 2 revisions

Packagist Version Donate with PayPal License BSD 3-Clause Follow JV conseil – Internet Consulting on Twitter

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

Installation & loading

DkimPhpMailSignature is available on Packagist (using semantic versioning), and installation via Composer 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

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

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:

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: 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.

Documentation

Documentation is available online, 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 installed.