It’s a common problem for contact form submissions and other emails to not be received from websites, the solution to this would be to have all outgoing emails copied to the database – ensuring the messages are never lost. There are plugins that already do this but they all have their own major flaws which made them inappropriate for my use.
So I opted to create my own, the objectives were:
- It had to be very simple to use
- Fast and lightweight
- Be futureproof and easy to extend by others
- Completely free to use (no adverts, trailware or nagging messages)
The plugin follows a model view controller (MVC) approach, this helps keep all functionality isolated and allows other developers and designers of very junior levels to contribute changes which is great!
While the codebase is certainly a critical component in ensuring the plugin is futureproof, the other aspect is automated testing. The plugin has unit testing and continuous integration with TravisCI which allows the unit tests to be automatically run on various WordPress versions and PHP versions on each commit. While not foolproof it is a critical part of ensuring the plugin remains robust as WordPress and PHP continue to move forward.
The end result turned out well, clocking in at under 1MB in size with no setup required – just activating the plugin will ensure your messages are saved. It is also easy to extend – incase of future changes to wp_mail or to add additional plugin support.
This was done by using the “adapter” design pattern (also dubbed “drivers” in Laravel) this allows the entire process of saving a message to be encapsulated into a single class, if a new plugin comes out that handles wp_mail in a different way, only a single new class needs to be written to add support.
The shallow learning curve makes it very easy for other developers to contribute pull requests, because they do not need to have an understanding of the entire plugin, only a basic understanding of object oriented programming.
The plugin is 100% free and can be downloaded on WordPress.org or via GitHub. I hope you find it useful!