Sending Domain Setup
In This Article:
- Add Domain
- Domain Verification
- SMTP/API Settings
- Tracking Settings
- Unsubscribe Settings
- Webhooks
- Sending Domains
To start sending emails with Mailtrap Email Sending, you first need to add and verify your domain. You won’t be able to send emails until your domain is verified.
Watch the video below or continue reading to complete the setup.
Step 1: Add Domain
- Navigate to Sending Domains in the left navigation panel.
- Type in the domain you want to send emails from and click Add Your Domain. Remember that you should be the owner of the domain with access to its DNS records.
- After this step, you’ll see the Domain Verification page.
Step 2: Domain Verification
At this stage, you need to verify the domain. You have two options:
- Send domain verification instructions to your admin or developer;
- Or verify the domain yourself if you have access to your domain’s DNS records (your hosting provider account).
To send instructions to your admin or developer, enter their email address and click Send Instructions.
If you use AWS, download the JSON file for AWS Route53 using the Download JSON button to create records using AWS CLI.
In the example below, we’ll be using GoDaddy. Detailed instructions for other popular providers are covered in separate articles.
To verify the domain yourself, follow these steps:
- Go to your hosting provider and locate the domain you’ve added to Mailtrap.
- Open the DNS settings and click Add New Record.
- Return to Mailtrap. You’ll need the values under Type, Name, and Value. The namings of these records in Mailtrap are the same as in most hosting providers but may differ slightly depending on the provider.
- Copy the Name and Value for each record one by one.
- And paste them into your DNS hosting provider.
- Make sure you check the type next to each record in Mailtrap and choose a relevant one in your hosting provider. There are four CNAME type records (Domain Verification, DKIM (2), and Custom Tracking Domain) and two TXT type records (SPF and DMARC). Read this article for detailed information on each DNS record.
- Click Save after adding each record to your hosting provider.
- Repeat the process of copying and pasting for each record until you’ve added all the Mailtrap DNS records to your hosting provider.
- Then, return to Mailtrap and click the Verify DNS Records button.
- Some records may be verified immediately, while some may take more time. Mailtrap will check the DNS records automatically every hour, but you can force a check by clicking the Verify DNS Records button again. The Status will change from Missing to Verified, and the red dot will turn green. Note: Some domains may be selected for a Compliance Check Process as part of anti-spam protection. In that case, the domain approval process may take longer. In more suspicious cases, we may ask additional questions regarding your sending volume and plans.
Several notes:
- 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.
Step 3: SMTP/API Settings
Once the domain is verified, the next step is to configure sending emails via Mailtrap in your app, project, or any email-sending service you use.
- Click Continue in the setup wizard.
- You’ll be redirected to SMTP/API Settings, and you’ll see Transactional Stream and Bulk Stream.
- Transactional Stream is used to send automated, non-promotional application emails that are triggered after the user completes a specific action. So, if you’re sending transactional emails, use the SMTP or API credentials under Transactional Stream. You’ll find sample configurations for multiple programming languages and frameworks.
- Bulk Stream is used to send a single marketing campaign to a large group of recipients in bulk. If you’re sending bulk emails, use the SMTP or API credentials under Bulk Stream. Here too, you’ll find code samples with your credentials in them.
- Transactional and Bulk streams have different endpoints, so make sure you choose the correct one.
- Copy the SMTP credentials for either stream and paste them into your project, app, or email sending service.
- If you prefer to use the API method, toggle the switch to API for each stream and view code samples for selected programming languages and frameworks. Click API References to view official API docs.
If you complete all the steps correctly, you’ll be ready to start sending emails with Mailtrap.
Step 4: (Optional) Tracking Settings
An optional step is to change the Tracking Settings. By default, Mailtrap tracks email opens for each email sent. You can also enable click tracking.
With tracking enabled, you will find the open and click rates in the Analytics reports. Read this article for a detailed breakdown of Statistics.
- Navigate to the Tracking Settings tab.
- Toggle the switch next to Track Opened Emails to enable or disable tracking opens. 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. Note: 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.
- Toggle the switch next to Track Clicks to enable or disable tracking clicks. 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. To use Custom Domain for Clicks Tracking, you need to verify it. Click Go to Domain Verification.
- You’ll be taken to the Domain Verification tab. There, you’ll find a DNS record for custom domain tracking. Add the record to your hosting provider and verify it, just as we did with other DNS records. If you verified all the records in Step 2, the custom domain for clicks tracking will already be verified. Once it’s set up, all links will be redirected through mt-link.yourdomain.com.
Step 5: Unsubscribe Settings
At this stage, you can configure Unsubscribe Settings.
Unsubscribe links are mandatory for bulk emails as per privacy laws. If your emails don’t include an unsubscribe link, Mailtrap will add an Unsubscribe Footer automatically. This is what it will look like:
To add an unsubscribe link anywhere in your template, include this tag in your HTML template: <a href="__unsubscribe_url__">unsubscribe</a>. Mailtrap will render a clickable link in your email.
Unsubscribe Footer and Links are optional for transactional emails and are switched off by default.
However, if you want to, you can still add an Unsubscribe Footer to your transactional emails by toggling the switch On under Unsubscribe Footer for Transactional emails or adding an HTML tag mentioned above.
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 bulk or marketing messages while still receiving vital transactional messages.
Step 5: (Optional) Webhooks
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 setup.
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.
Step 6: Sending Domains
After completing the setup process, you can always go back to the Sending Domains tab to add any additional domains or subdomains. If you, for example, misspelled a domain, you’ll need to delete it and re-add it with the correct spelling.
Remember that you can send emails only from domains that have green dots under Verification Status. If even one dot is red or yellow, it indicates that the verification isn’t completed, and you won’t be able to send emails from that domain.
From the Sending Domains menu, you can also delete the domains or subdomains you no longer use. Just press the bin icon next to the domain. 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 in the example below:
We do this to preserve your historical stats that would otherwise be lost.