Testing Magento Email with Mailtrap.io
May 26, 2016
Have you discovered how hard it is when testing Magento email? Have you ever tried getting Magento to use a separate SMTP server to send emails? I have, and got very frustrated with it. My solution to testing Magento email is to use Mailtrap.io.
Out of the box Magento doesn't provide any settings for using a different SMTP service other than the one your server is set up to use. (Well, it DOES, but only for Windows users). It can become time consuming If all you want to do is check the content of an email.
The solution I've chosen is to use Mailtrap.io as my SMTP service and inbox. From the Mailtrap website: “Mailtrap is a fake SMTP server for development teams to test, view and share emails sent from the development and staging environments without spamming real customers.”
They provide a free service and it is very easy to get started. Simply sign up and you are given an inbox and SMTP settings straight away.
As mentioned previously, Magento doesn't provide the option to use a different SMTP server by default. However, Ashley Schroder has created free Magento Extension called SMTP Pro Email that you can use to set up your SMTP service.
Here's how I set it up with Mailtrap.io.
Install the SMTP Pro Email Magento Extension
Install the SMTP Pro Email extension from Magento Connect, or alternatively, from the SMTP Pro Email Github Repository. I use
modman to manage extensions on my Magento sites, so installation was easy:
cd public_html/ modman clone https://github.com/aschroder/Magento-SMTP-Pro-Email-Extension.git
Once that is installed, log into the admin area and browse to System > Configuration. On the left there should be a new menu section, 'ASchroder Extensions', with a link to the 'SMTP Pro' configuration.
After browsing to the SMTP Pro configuration you should see the following settings panel:
Getting the SMTP details from Mailtrap.io
Add the SMTP settings to Magento
Go back to your Magento tab and enter the SMTP settings from Mailtrap.io These are:
- Email Connection: Choose 'Custom SMTP'
- Authentication: Choose 'CRAM-MD5'
- Username: Your Mailtrap username, usually a string of alphanumeric characters
- Password: Your Mailtrap password, again, a string of alphanumeric characters
- Host: 2525
- SSL Security: Choose 'SSL TLS' (although any option should work)
Once you've entered these settings click 'Save Config' and test. A quick way to test that it works is to go to Customers > Manage Customers and change your own password. Magento will send an email immediately, and you should see it turn up in your Mailtrap Inbox:
And that's it. All other emails sent from your Magento store will appear in your Mailtrap.io inbox.