Sending Domain Setup
In This Article:
- Add Domain Name
- Domain Verification
- Cloudflare Setup
- Google Domains setup
- GoDaddy setup
- Completing the verification
- Tracking Settings
- Unsubscribe Settings
- Deleting a domain
Before you send any email from Mailtrap, you need to add and verify at least one domain. This is a security measure designed to ensure that you’re a legitimate sender and have the rights to send on behalf of a given organization.
Often, the domain is the same as your company website - for example, companyname.com. You’re free, however, to use any domain address, as long as you can prove its ownership. Note that you won’t be able to add public domains to Mailtrap.
You can, however, add multiple domains as well as subdomains. A common practice is to send, for example, transactional emails from transactional.mailtrap.io and marketing messages from marketing.mailtrap.io. Each subdomain needs to be added to Mailtrap separately.
To successfully pass verification, you must add five records to your domain’s DNS:
- CNAME record used to verify the domain
- SPF record
- DKIM records (2)
- DMARC record
All five records are required to be able to send emails with Mailtrap. You can add them via your domain registrar or manager.
Click below to watch our Domain Setup video or continue reading to complete the setup.
Add Domain Name
To add a new domain, select Sending Domains from the Sending menu. Here, insert the domain you want to add and press Add Your Domain.
If you’ve already added some domains before, you can use the Add Domain button to add any further domains or subdomains. If you, for example, misspelled a domain, you’ll need to delete it and re-add it with the correct spelling.
On the next screen, you’ll see the list of records to be added.
The first CNAME record is used to prove to Mailtrap that you are indeed the owner of a domain.
SPF, DKIM, and DMARC are common email authentication methods. They aim to prevent spoofing and phishing attempts on your account.
What’s more, having authentications in place sends a message to mailbox providers that you’re a legitimate sender. As a result, they treat your emails more favorably and more emails get delivered to the recipients.
Depending on the domain provider you use, the process may look a bit different. Below we show examples for Cloudflare, GoDaddy, and Google Domains.
If you use AWS, rather than copy the records, you can copy the JSON file for AWS Route53 using the relevant button.
If someone handles the DNS management for you, you can send them the whole configuration at once. Press the Copy all settings as text button and then paste them into an email or elsewhere. You may also invite them to your Mailtrap account via the User Management tab.
- If you already have an SPF record, don’t add another one for Mailtrap. Instead, edit the existing record. To make it easier, Mailtrap will automatically check if there’s an SPF record associated with your domain. If it finds one, it will offer an updated version, for example: v=spf1 include:_spf.google.com include:sendgrid.net include:_spf.smtp.mailtrap.live ~all. Insert that in your DNS.
- Some domain providers don't allow setting ‘@’ for SPF records. In this case, please use your own domain name "example.com" instead of '@'.
- Some domain providers require a postfix format of the DKIM record. If that’s the case, replace rwmt1._domainkey with rwmt1._domainkey.yourdomain.com. Repeat the process for rwmt2._domainkey, changing the name to rwmt2._domainkey.yourdomain.com.
- If you’re asked to set TTL, use the default value.
To set things up on Cloudflare, open the dashboard and click the domain you want to add the records to. Make sure that the domain is identical with what you just added to Mailtrap. Then, go to the DNS menu.
Click the Add record button and add the respective records, one by one. Add Type, Name, and Value precisely as stated in Mailtrap. The Category field won’t be needed in this case.
- When adding a CNAME type, Mailtrap’s Value field is referred to as Target. When adding a TXT type, it’s Content.
- If you use a proxy, make sure it’s disabled for each applicable record. By default, it will be enabled.
- Make sure you add an SPF record as TXT type, as stated in Mailtrap. Don’t use Cloudflare’s SPF type as the record won’t be verified correctly.
Here’s a sample configuration:
Google Domains setup
For domains managed via Google Domains, the process is very similar. Log in to your account and choose the domain you just added to Mailtrap. Then, go to DNS menu.
- Google’s Host name is the same as Mailtrap’s Name. Similarly, Google’s Data is equal to Mailtrap’s Value field.
- Add SPF record as TXT type, ignoring Google’s SPF type. Records added this way won’t be verified correctly.
- When adding the SPF record, don’t add anything in the Host name field.
Here’s a sample setup:
To set things up on GoDaddy, log in and click on the domain you wish to add the DNS records to. Scroll down to Additional Settings and select Manage DNS there.
You’ll see the current list of DNS records for this domain. Click Add to add the ones you can see on Mailtrap, one by one.
The naming on GoDaddy is identical to what you see on Mailtrap, so it’s pretty straightforward. Here’s a sample set of the required DNS records added to our account:
Completing the verification
Once you’ve added all five records to either provider, press the Verify all button on Mailtrap. If all circles turn green, you’re good to go, and can press the Next button in the bottom-right corner.
Sometimes a domain provider doesn’t publish the changes to DNS immediately. If some or all records are not correctly verified, double-check that you added them properly. If everything checks out, give it some time. You may press Next to proceed to the next step and go back to the verification stage a bit later.
Mailtrap checks for updates every hour or when the Verify all button is pressed. In rare cases, it may take up to 72 hours until the changes are reflected in your DNS.
API and SMTP
The next step is to configure sending emails via Mailtrap in your app, project, or any email sending service you use. There are two ways to go about this: via API or via SMTP.
If API is your choice, pick any of the examples from the drop-down menu to send a test email into Mailtrap.
Alternatively, use the SMTP configuration and add it to an app or a service you use.
Once you’ve made up your mind, send a test email and press the Verify button to the right. A 2-minute countdown will start during which we’ll be checking if your email has arrived. If an email arrives, you’ll shortly see the following screen:
You can now go to Email Logs and see the details of an email you just sent with Mailtrap. Click on the subject line to go into a more detailed view.
If after two minutes no email has been found, you’ll see the following screen:
If you’re confident that you configured everything correctly, feel free to run the test again. Sometimes it may take up to 5 minutes for an email to arrive. If the problem persists, resend the email and try again. Alternatively, contact us so we can assist you further.
Note: if you complete verification and leave the domain verification wizard, the menu will look different on your next visit. It will lack the initial configuration steps because you’ve completed them already. Everything else will remain the same.
The next step is to (optionally) change the tracking settings. By default, Mailtrap tracks email opens and clicks for each email sent. You can monitor the statistics individually for each message via Email Logs or see the aggregated data in the Stats tab.
Mailtrap tracks email opens via an invisible pixel. It’s added to each message sent from your account. When an email is opened, a pixel is loaded and an ‘open’ event is recorded. Each of these events will be visible in Email Logs.
Some mailbox providers, browsers, and extensions block invisible pixels. Users can also choose not to display images or a solution they use to retrieve emails may not support images by default. In each of these cases, an ‘open’ event won’t be recorded even if an email is opened.
If you enable click tracking, all links will be redirected through the t.mailtrap.live domain which will allow us to accurately track each click.
If you’re not comfortable using Mailtrap’s URL in your emails, you can instead use the domain you’ve just verified. It won’t affect the click tracking in any way.
Enable Use Custom Domain for Clicks Tracking below. Insert a DNS record as stated below, just as you did before for authentications and the domain authentication record.
Then, press Verify. Just as was the case before, it may take some time (up to 72 hours again) before the change is reflected.
Once it’s set up, all links will be redirected through mt-link.yourdomain.com.
Next you should decide on the unsubscribe links. Privacy laws around the world require you to include unsubscribe links in all sorts of marketing and sales emails.
We strongly encourage you to follow this rule. If someone doesn’t want to hear from you, they’ll gladly unsubscribe. If they can’t find such an option, they’ll probably report your message as spam. This will have a negative effect on your sender reputation and email deliverability.
You’re not required to use an unsubscribe link in transactional emails, though, and usually it doesn’t make any sense to do so. After all, you don’t want your users unsubscribing from password reset or order confirmation emails, do you?
- Include the following HTML in the copy of your email: <a href="__unsubscribe_url__">unsubscribe</a>. It will create a URL with a link to unsubscribe.
- Enable Unsubscribe Footer and Mailtrap will automatically add a footer with a link to each email you send. You can preview how it will look like here. At this point, the content of the footer can’t be changed but we’ll certainly enable it in the future.
- If you’d like, you can mix both approaches - automatically add a footer to emails sent from one domain and do it manually (when applicable) for emails sent from another domain.
If an end-user uses an unsubscribe link, Mailtrap will reject any future emails sent to this address from this particular domain. You can quickly find all such emails in the Email Logs by filtering by a “reject” event.
You will still be able to email them using other domains or subdomains added to your Mailtrap account.
For that reason, it’s worth having different domains or subdomains for different types of emails. This way, users can, for example, unsubscribe from your marketing messages while still receiving vital transactional messages.
Lastly, you can set up webhooks to receive event information almost real-time.
Click the Add New Webhook button, paste the webhook URL (your endpoint) into the designated field, select the events you want to listen to, then test the set-up.
Mailtrap also allows you to batch up to 500 events within a webhook; that is - group all events under one object, and thus save on computing power.
To read more about webhooks setup, events structure, and batching, check this article.
Deleting a domain
If you change your mind about any of the domains you added, you can always go back to the Sending Domains menu and use the bin icon. This will remove the domain from the list and you won’t be able to send any further emails until you add and verify it again.
Note that removing a domain won’t remove it from your Mailtrap account completely. It will still appear, for example, in analytics, and will be displayed with the (deleted) suffix, just like on the example below:
We do this to preserve your historical stats that would otherwise be lost.