Testing email functionality in Dynamics 365 for Finance and Operation takes time and might not be so fun. There is an overwhelming number of email testing scenarios.
Imagine that you are testing emailing of invoices or collection letters in D365FO that is constantly filling up your inbox with test email messages. At worst, you could receive or send over hundreds of test emails. This high volume of messages in your inbox is absolutely not what you want to end up with.
Or let’s say you want to see what the emails that will be sent out from D365FO look like, but you don’t want the recipients to actually receive them. As we know, there is no undo button after the email is sent.
According to this, regardless of whether you’re creating every email from scratch or using pre-existing templates, it is a necessity to make sure that your emails are designed and addressed correctly.
Also, you will probably agree that it can get frustrating when the sending emails out from D365FO is failing and you don’t know what causing the error. So instead of focusing on the resulting email messages, you are losing time on configuring your Exchange server and changing emailing settings in D365FO.
One good way to overcome all these situations is to use an email testing tool.
In this article, we will show you how to use a free tool called smtp4dev with D365FO that allows you to view and inspect outgoing emails without sending them to the recipients.
Let’s start with a short overview of the tool.
Introduction to smtp4dev
In this article, we will stick to the smtp4dev Windows GUI 2.0.10 version, which can be downloaded from GitHub, and which is by our opinion easier to use than the latest version.
Download the MSI installer package file from GitHub and install it. When the installation is completed, you can run smtp4dev from the Windows Start menu or from the automatically added system tray icon. Once it has started, the main screen is open as shown on the image below.
The user interface is simple and intuitive. On the main screen you will see two tabs: for Messages and for Sessions.
Under the Messages tab, you can see the details about received emails such as receiving time, email subject and recipient addresses. There are also options to view, inspect and delete emails, or to save them locally in EML format. If you click the View button, the selected email message will open in the default email client (in our case it’s Outlook). By clicking the Inspect button, you can explore the email structure where the information is grouped into the Source, Headers and Body part. Here you can find the information about the sender, recipient, subject, content-type, sending date, attachments, etc.
Under the Sessions tab you can see the SMTP session details such as email date and time, the client IP, and how many emails were sent within the session.
At the bottom of the main screen is the Start Listening/Stop Listening button that is used for start/stop of the listening process, and the Options button for configuration settings.
By default, the smtp4dev listens on 0.0.0.0 (all interfaces) at port 25 and keeps the 100 messages and 100 sessions. You can specify the maximum size of a message, set the timeout, set the domain name, enable SSL/TLS connections, etc.
As you can see, smtp4dev has a plenty of configuration options you can use if needed. Now, let’s see how we can use it with Dynamics 365FO.
Before we start
Let’s say that we want to send invoices via email to our customers from D365FO with some additional attachments and useful information in the email body such as invoice number, customer name, method of payment, due date, etc. To test how such outgoing emails look like, we will use smtp4dev.
In one of the next articles, we will explain troubleshooting techniques for solving emailing issues you might stumble upon when using a real mail server.
How to configure smtp4dev server in D365FO
As already said, smtp4dev can be used for development and testing purposes, and it’s not recommended to be used in production environments.
First, start smtp4dev and click the Start Listening button.
The next step is to configure SMTP settings in Dynamics 365FO. Navigate to System administration > Setup > Email parameters and click the Configuration tab, then set Batch email provider to SMTP.
Next, click the SMTP settings tab. Here we need to enter parameters for smtp4dev as follows:
Set Outgoing mail server to localhost and SMTP port number to 25.
Optionally, we can set the user name and password for the SMTP sender email account.
Configure smpt4dev to work with UAT environments
If you can connect via RDP to the VM with your UAT environment, then you can install smpt4dev on this machine directly. If this is not the case, there is still a way to use smpt4dev. Learn how >>
That’s all. Not so hard, right? 😊
Now we are ready for testing emails with smtp4dev.
Print Sales invoice using Docentric Email print destination
You can also use smtp4dev for SSRS Email print destination but in this article, we will rather focus on the Email print destination improved by Docentric. Namely, besides the email body, the Bcc field, and additional email attachments, when using Docentric you can also specify the email sender address, i.e. the From field.
Learn how to troubleshoot such emailing issues >>
We will email an invoice from Invoice journal by using Print management settings. Open Print management setup, locate the Customer invoice report, select Docentric Email as the target print destination and set up the email print settings including the email body, subject and attachment name. We will use placeholders such as @Invoice@, @InvoiceId@, @InvoiceAccount@ and @InvoicingName@ to make them dynamic.
Now navigate to Accounts receivable > Inquiries and reports > Invoices > Invoice journal, select one invoice and run it by clicking View > Use print management.
The selected invoice is being emailed and the outgoing email is caught by smtp4dev, where you can view it and examine in detail. Note that the placeholders we used in the email body, subject and attachment name are replaced with the corresponding data. You can also see that the primary email contact token and the @Invoice@ purpose are resolved as the email addresses of the invoice customer.
Furthermore, by clicking the Inspect button, you will be able to see the detailed message information such as the sender, recipients, subject, attachments and more. Note that this email message has not been sent to any inbox, and we can still see how it looks like.
By using smtp4dev, you can test emailing in D365FO without configuring Email parameters in D365FO to use your real mail server. Consequently, you don’t have to configure your real mail server either, which can be a demanding task and can be done separately.
In other words, you can separate the process of designing and configuring outgoing emails through the email print settings in Print management in D365FO, from the process of real mail server configuration.
smtp4dev is a handy, simple and free email testing tool, easy to configure and use with D365FO. It can help you with the testing of emailing scenarios in D365FO such as emailing reports and workflow email notifications, by intercepting the outgoing emails without sending them to the recipients. By using it, you can verify the content and inspect the structure of D365FO outgoing emails without configuring your real mail server, which can be a challenging task that you can do separately and at any time later.