How to Install and Configure
How to Install the Mailjet Module¶
- Go to the Mailjet Plugin page in the Drupal website and download the plug-in, or copy the download link to your clipboard.
-
Log into Drupal as the Administrator, click on ‘Modules’ and then on ‘Install new module’.
-
Paste the plug-in download link in the ‘Install from a URL’ field, or choose the downloaded plug-in file from the ‘Upload a module or theme archive to install’ menu. Afterwards click on ‘Install’.
-
Once the installation is successful, from the Drupal admin menu select ‘Configuration’.
-
From the ‘System’ section choose ‘Mailjet Settings’.
-
In the Mailjet Settings page, select the ‘API’ tab.
You will need to enter your Mailjet API Key and Secret Key. This will replace your default SMTP information and allow Drupal to send all your emails through Mailjet. You can find the API Key and Secret Key information in your Mailjet API Key Management page.
Note
If you do not have a Mailjet account, please create one now by clicking the ‘Register’ button on the API tab, or go directly to the Mailjet Signup page.
-
Enter your API Key and Secret Key as shown below, and then click on ‘Save configuration’.
Important
The API and Secret keys are authentication tokens only known by you and Mailjet. Please keep them private.
Once your configuration is saved, your Mailjet account will be linked to Drupal. Your Drupal contacts will be automatically transferred to a new Mailjet Contact List, along with the contact properties configured in Drupal.
How to Configure the Mailjet Module¶
Select Mailjet Sender Email Address¶
The Mailjet module uses the sender email address you have selected for your website in the Drupal settings.
Important
In order to be able to successfully send emails via the Mailjet module, the sender email needs to be verified with Mailjet. Visit the “Sender Domains & Addresses” section of your Mailjet account to view your sender addresses and domains.
To view / change your site’s email address, select ‘Configuration’ → ‘System’ → ‘Site Information’ from the Drupal admin.
Then enter an email address that is verified in Mailjet and click on ‘Save Configuration’ to save your settings.
Add Mailjet Settings Shortcut¶
To be able to quickly access the Mailjet module, it is useful to add a shortcut to it to your ‘Default shortcuts’.
Simply go into ‘Mailjet Settings’ and click on the +
sign next to the module name.
The shortcut will immediately be added to the respective menu.
Settings Tab¶
Let’s examine the sections in the Settings tab and how you can configure them. Please remember that for any changes to take place, you need to click on ‘Save Settings’ afterwards!
Send Test Email¶
The first step is to send a test email and verify that the Mailjet configuration is correct.
Click on the ‘Send test email’ button.
Enter an email address and click ‘Send Test Message’.
Check your inbox for an email with the subject “Your test mail from Mailjet”.
Note
If you do not receive the test email in your Inbox, make sure to check the Spam folder, as well as your email sending configurations. If after that you are still experiencing difficulties receiving the test messages, please reach out to our awesome Support Team, who are always eager to help!
Excellent, the Mailjet module is correctly configured!
Send Emails through Mailjet¶
Now for the most important setting - check the “Send emails through Mailjet” box.
By enabling this checkbox, you are allowing Mailjet to send all of the emails emanating from your Drupal environment (transactional emails and marketing campaigns). With Mailjet’s SMTP relay, you will have access to real-time statistics, triggered marketing events, order statuses, ROI on campaigns, optimized email deliverability and much more.
Allow HTML¶
Tick this checkbox, if you want your emails configured and sent from Drupal to include HTML code. If the option is not enabled, Drupal emails will be automatically converted to plain text by Mailjet.
Event Tracking¶
The next step is to select the events to be tracked automatically with the Event Callback URL.
Event Callback (or Tracking) simply means whenever there is an event, information about it is dispatched to the provided Callback URL, containing meaningful context about the event (like the recipient email, timestamp, etc). From here, the customer can script actions to be done following it.
To start tracking email events of your choice, first choose the ones you are interested in by ticking the checkboxes next to them in Drupal. In the below example, we have selected only the ‘Unsub’ event.
Note
You can see descriptions for all email events in the Mailjet Email Statuses Guide.
Then copy the displayed Event Callback URL and paste it into the Event Tracking page of your Mailjet account:
- Tick the checkbox next to all events you want to track.
- Paste the URL into the ‘ENDPOINT URL’ boxes of the respective events.
- Click on ‘Save’ to submit the changes.
A message will appear informing you about the events you are tracking now.
Note
All tracked events will be automatically recorded in a mailjet_event
table in Drupal, but only if the email address of the recipient matches the email of a registered user in Drupal. You can call up this table in your PHP scripts to create automated processes in Drupal.
Account Information¶
The last section of the Mailjet module’s ‘Settings’ tab is the (Mailjet) Account Information.
Changes made here will be automatically reflected in the Profile page in your Mailjet account.
Again, remember to click on ‘Save Settings’ when you make any changes!
Mailjet API¶
Configure the default SMTP settings to send all email through Mailjet.
API & Secret Key: You have already entered this information but in the event that you get a new API & Secret Key, you would simply update the information here.
The ‘Event Callback URL’ section here shows the same URL displayed in the ‘Event Tracking’ section.
Mailjet Domains¶
This tab will list all the configured domains you have as per the Sender Domains & Addresses page of your Mailjet account. By configuring an entire domain, you can add sender addresses from that domain without having to manually validate each one.
To add and configure a new domain, click on ‘Add Trusted Domain’, then enter the domain name and click on ‘Add’.
Once added, you will see the domain being added to your list of trusted domains, but will be shown as ‘Inactive’.
To activate it, you need to upload an empty .TXT file with the file name shown next to the root directory of the respective site. Then go back to the Mailjet Domains section and click on ‘Check Status’.
Mailjet will check if the file exists on the site, and once it finds it, the domain will be validated. Afterwards you can delete the .TXT file.
Congratulations! You have completed the installation and configured of the Mailjet module.
Using Event Tracking with Drupal Rules¶
You can use Event Tracking to create automated processes in Drupal, saving yourself valuable time and effort. This can be done either by creating PHP scripts yourself and implementing them in Drupal, or by using Drupal Rules.
Note
To use Drupal Rules, you need to install the Rules module in your Drupal admin.
To access the Rules module, go to ‘Configuration’ → ‘Rules’.
Select the ‘Add new rule’ option to start creating your Rule.
You will need to choose a Rule Name, as well as select the trigger - the event, which will activate the rule. You will find the Mailjet events in the drop-down menu under ‘Mailjet’ and ‘Mailjet event’.
Click on ‘Save’ to save your trigger event selection.
You will then need to select additional conditions, as well as the actions your Rule should undertake when it is triggered.
Once you have configured your Rule, click on ‘Save changes’ and it will become active!
Where can I find more information on Rules and how to configure them?
Since there are numerous ways you can configure your Rules, we highly recommend that you check Drupal’s All About Rules guide.