Setting up email with MODX using Mailjet
published onThis post is intended to show you how to add the ability to send emails to MODX. We use Mailjet here but there are a number of other providers that will serve the same purpose.
Getting started
The first thing we need to do is to create an account at https://www.mailjet.com/. Click on Get Started and enter your email and an account password to set up a new Mailjet account.
Fill in the details they ask for, choose Next and then Complete Order. You will receive an email asking you to activate your account. Click on the button in the email to do so.
Setting up Mailjet
Once your account has been activated click on your account name in the top - right - hand corner and choose Account settings.
We are going to set up DNS records to ensure emails get delivered.
As you can see your email address is already listed as a valid sender address. At the moment this is the only address that Mailjet will send emails on behalf of. If you need to send from other addresses at the same domain you can click on Add domain or Add a sender address and follow the prompts.
At the top of the page you will see Domains and Sender Addresses underlined. To the right of this you will see SPF/DKIM Authentication. Click on this and you will see your domain listed along with a missing tag under the SPF and DKIM status.
Click on the cog icon on the right and then on Setup SPF/DKIM Authentication. You should now see two sections - one for SPF and one for DKIM. They will tell you what DNS records you need to add.
Once you have added the DNS records return to Mailjet and click on Refresh. It may not always update immediately but if you get an error message try returning to the Sender domains & addresses section of your account and you may see that the SPF and DKIM status has now updated to OK.
Find our your email details
Head back to your Account Information page and click on SMTP and SEND API Settings. You should see two boxes, one above the other. The bottom box contains the SMTP server name and port number to connect to.
To get the details in the top box click on the See all API credentials button. Then click on Generate secret key. A box will pop up containing an API key and a secret key. These are your username and password respectively. Make a copy of them and keep them in a secure place.
Once you have made a record of the details described above click on Done. You have now finished with Mailjet.
Setting up MODX
Login to your MODX manager console (the backend of your site), click on the cog icon in the bottom left and then click on System Settings.
Use the arrow buttons at the bottom of the page to navigate to the Area: Mail settings. Edit the following settings:
SMTP Authentication: set to yesSMTP Auto TLS: set to yesSMTP Hosts: set to in-v3.mailjet.comSMTP Password: add your secret key hereSMTP Port: set this to 465 here (if that doesn't work try 587)SMTP User: add your API key hereUse SMTP: set to yes
Testing the settings
In order to test that the setting you have entered are working click on Extras on the left - hand side and then click on Installer. Click on Download Extras and enter QuickEmail into the search box before hitting Enter.
Once the package appears click on Download and wait a few seconds. Once the package has been downloaded click on the cube icon to the left of Package Browser. Now click on the green Install button. Next click on the Continue button and finally on OK.
Click on the arrow at the top - left to display the Resources tab. Click on the + on the right of the word Website. Enter a title of Email test and change the Uses Template section to (empty) then click Save.
In the Content field add
[[!QuickEmail? &debug=`1`]]
and make sure to select Published and Hide From Menus. Save the document.
Now click on View. You should see some information about whether an email was sent or whether an error occured.
If an error did occur you will have to use the information provided to work out what the problem is. It is likely that one of your settings may be incorrect and you may need to revisit the Settings before trying again.
