Email testing in UAT environments

UAT environments are used for User acceptance testing (UAT) and usually operate with the production data, i.e. with the database copied from the production environment. Consequently, all email addresses from Global address book and email print settings from Print management setup are copied from the production to UAT environment as well.

For example, if you have configured Sales invoice to be emailed to the primary contact email of the customer in the production environment, these settings will be copied as such to your UAT environment. And if you don’t change them, first time when you post and print an invoice in UAT, it will get emailed to the real customer’s email address.

Suppress outgoing emails

It’s certainly annoying to keep updating email settings each time when the production database is copied to your UAT environment to prevent accidentally sent emails from D365FO. That’s why in Docentric 3.3.9 version we introduced a new handy feature Suppress outgoing emails, which enables you to block all outgoing emails handled by Docentric with a button click. This includes all reports emailed through Docentric Email print destination and all outgoing emails emailed via Docentric Email distributor batch.

Testing instead of blocking outgoing emails

However, what if you actually need to test outgoing emails in your UAT environment? In the previous article, we explained how to install and configure a fake SMTP server used for email testing, smtp4dev, in a D365FO development environment.

smtp4dev is a cross-platform fake SMTP mail server, which is completely free of charge, designed to help developers and testers to intercept and inspect emails that are sent out from their applications. Instead of sending an email to the recipients like a regular SMTP server, smtp4dev will simply catch the outgoing email and notify you.

If you can connect via RDP to your UAT environment, you will be able to install and configure smpt4dev directly on the UAT VM (Virtual Machine) since the installation can be done with Xcopy deployment. In this case, the procedure is completely the same as for development environments. Learn the procedure > >

However, usually this is not the case, e.g. in a self-service deployment UAT environment there is no VM to connect to, and consequently remote desktop access is out of the picture 🙂 . Luckily, you can still use smpt4dev for email testing, but it has to be installed on a separate machine with a public IP and the firewall configured to have the smpt4dev’s listening port opened. Such a machine you can then use for email testing in multiple environments.

Sounds complicated? Not if you follow the steps from this article! You will learn how to install and configure smpt4dev on a DevBox VM deployed in Azure, and which configuration steps to take next to enable this VM to receive test emails sent out from your UAT environment.

Configure DevBox VM in Azure

Follow the next steps to configure DevBox VM that is hosted on Azure to be able to receive emails from an UAT VM via smtp4dev:

Step #1: Install smtp4dev on DevBox VM in Azure
Step #2: Finding the public IP address of DevBox VM
Step #3: Configuring SMTP security rule in network security group
Step #4: Configuring inbound NAT rules
Step #5: Configuring firewall settings

Step #1: Install smtp4dev on DevBox VM in Azure

The procedure is the same as described in the previous article. The only difference is that we need to set up the listening port to 587 in the smtp4dev configuration settings.

There are a few standard port numbers for SMTP: 25, 465, 587. SMTP port 25 continues to be used as a primary port for SMTP relaying but in most cases modern SMTP email clients shouldn’t use this port. It could be blocked by ISPs and Cloud Hosting Providers so our recommendation is to use the port 587. For more information, please read Troubleshoot outbound SMTP connectivity issues in Azure.

Step #2: Find the public IP address of DevBox VM

There are many ways to determine the public source IP address of an Azure VM. For example, you can find out the public IP address by using:

  1. Azure portal
    • Sign into Azure portal at
    • Type Virtual machines in the search box and select your DevBox VM.
    • In the Overview tab see Public IP address.

    Note: There are many places in Azure where you can read the public IP of an VM.

  2. Command prompt
    • Open Command prompt.
    • Ping the URL of the UAT server.
    • See how the URL is resolved into IP.

Step #3: Configure SMTP security rule in network security group

A network security group contains security rules that allow or deny inbound network traffic to a VM, or outbound network traffic from a VM. For each rule, you can specify Source and Destination, Port, and Protocol.

Follow these steps to create an inbound SMTP rule for the port 587 for your DevBox VM:

  1. Sign into Azure portal at
  2. Type Virtual machines in the search box and select your DevBox VM.
  3. Under Settings select Networking.
  4. Select Inbound port rules and then click Add inbound port rule.
  5. In the Add inbound security rule page, toggle to Advanced from Basic at the top of the page.
  6. In Destination port ranges enter 587.
  7. Optionally, change Priority or Name.
  8. Click Add to create the rule.

Step #4: Configuring inbound NAT rules

A load balancer inbound NAT rule is used to define binding of a specific public IP/port on the load balancer to the specific IP/port on VM in the backend address pool. To add an inbound NAT rule, you need to follow these steps:

  1. Select All resources on the left menu, and then select Load balancer connected to DevBox VM.
  2. Under Settings, select Inbound NAT rule, and then click Add.
  3. On the Add inbound NAT rule page, type or select the following values, if not already presented:
    • Name: Type SMTP4Dev.
    • Frontend IP address: Select the IP of your DevBox VM.
    • Protocol: Select TCP.
    • Port: Type 587.
    • Target virtual machine: Select your DevBox VM.
    • Network IP configuration: Select the private IP of your DevBox VM.
    • Port mapping: Select Default.

Step #5: Configuring firewall settings

To allow the smtp4dev app to communicate through Windows Firewall take the following steps:

  1. Open Windows Firewall.
  2. Select Allow an app or feature through Windows Firewall.
  3. Select the smtp4dev app and then tick Private and Public checkbox as well.

    If you don’t see the smtp4dev app on the Allowed apps and features list, click the Change Settings button at the top-right corner, and then follow these steps:

    • Click Allow another app near the bottom.
    • Click Browse, select the app, and then click Open.
    • Click Network Types near the bottom-left corner, select a privacy preference, and then click OK.
    • Click Add to add the app.
  4. Click OK.

    Note: The smtp4dev app must be installed on DevBox VM before configuring Windows firewall.

Test emailing in UAT using externally installed smpt4dev

Let’s now set up Email parameters in UAT environment to use just installed and configured smpt4dev on your DevBox VM in Azure. Afterwards, all emails sent from your UAT will be caught up by smpt4dev. This way you will be able to use exactly the same email settings from your production environment for emailing reports but not sending them to the real recipients – your customers and vendors. At the same time, you will get the chance to verify your outgoing emails and take a closer look at the messages’ bodies and headers, fields To, Cc, Bcc, etc.

Setup Email parameters in UAT

  1. Login to UAT environment.
  2. Navigate to Email parameters.
  3. Under Configuration select SMTP as Batch email provider.
  4. Under SMTP settings type following values:
    • Outgoing mail server: DNS name of your DevBox VM, which you can read from the Overview tab in Azure.

    • SMTP port number: 587
    • User name: any email address; it will act as a sender account.
  5. Under the Test email tab select SMTP as Email provider and fill in Send to with a recipient email address.
  6. Click Send test email.


Monitor outgoing emails on DevBox VM in Azure

On your DevBox VM in Azure, open smpt4dev; you will see that the sent test email has appeared. Congrats, you can now send emails from D365FO in UAT, e.g. by emailing reports such as invoices and orders, and monitor how they are arriving in smtp4dev on DevBox VM in Azure.

Learn how to configure and use smtp4dev >>

Leave a Reply

Your email address will not be published. Required fields are marked *


Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>