Software testing is a key aspect of writing an high-quality code, and helps ensure that any future changes don’t unexpectedly break anything. Automation increases the repeatability of this task and is easily applied to Laravel.
Many modern web apps use email to send welcome information or notifications to users based upon certain events. Even with a well setup test environment, you will want to stop possible hundreds or thousands of test emails being sent. And there is an easy solution.
You probably found this post because you already know what DKIM is and want to implement it, but for those of you who need more information Wikipedia has a good entry on the subject;
This little walkthrough has been based upon a Ubuntu 12.04LTS server with Postfix; your mileage may very depending on your setup. At a minimum you will need:
Root access to your mail server
Access to update the dns records for your domain
Firstly, install opendkim from the repositories. There is some good information available there too.
sudo apt-get install opendkim
You must decide on what “selector” you wish to use. The selector is essentially a word to describe the key you wish to use. Here I am going to use the selector 201204 as the key became valid in April 2012 (cunning eh?). Obviously, my domain will be brabeum.com.
So onward. Generate the keys in your home directory, using your chosen selector and domain.
opendkim-genkey -s 201204 -d brabeum.com
This will create two files, 201204.txt and 201204.private containing the public and private keys respectively. You must publish the content of the public key to your authoritative DNS server. Three things to note;
openDKIM 2.5.2 on Ubuntu omits the k= after v=DKIM1;
you should add the t=y flag to indicate to receiving servers that you are testing DKIM but not actively using it yet.
You should use a short TTL (time to live) so that you can change the key without waiting ages for it to propagate though DNS.
DNS implementations vary, but you should end up with an entry something like this (I’ve shortened the key because of line breaks);
201204._domainkey IN TXT v=DKIM1; k=rsa; t=y; p=MIGfM..[snip]..QIDAQAB
Remember to reload your DNS configuration after addition.
opendkim-testkey: key loaded from 201204.private
opendkim-testkey: checking key '201204._domainkey.brabeum.com'
opendkim-testkey: key not secure
opendkim-testkey: key OK
Note that opendkim is reporting that the key is not secure. This relates to the fact that DNSSEC is not implemented on my DNS server and theoretically somebody could intercept the DNS lookup and replace it with their own key.
Once we are happy with the key test, move the private key to /etc/mail
sudo mv /home/basil/201204.private .
Setup openDKIM by editing /etc/default/opendkim with your favourite editor and add the following line to the end.
Then edit /etc/opendkim.conf and add the following lines
So now you need to send some test messages through your newly configured postfix server. At the receiving end you should see some new headers, one of which will show similar to below (note that Google recognize it as test mode as we still have the t=y flag applied).
Once you are happy that all is well, you can remove the testing flag and increase TTL.
Privacy & Cookies Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.