Use SMTP4DEV for testing emails without sending in D365FO

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.

The latest version of smtp4dev has Web UI. It can be downloaded from GitHub as well.
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. This means instead of sending an email forwards like a regular SMTP server, it will simply catch the outgoing email and notify you.

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.

These are default parameters from the smtp4dev configuration settings. If you have changed them in smtp4dev, enter the changed values in Email parameters > SMTP settings in D365FO.

Optionally, we can set the user name and password for the SMTP sender email account.

For User name and Password you can set whatever you want, or even leave them empty.

 

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.

If you set up the From field, this might cause that your outgoing emails fail to be sent.
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.

 

You can configure popup notifications to show when a new message is received in smtp4dev.

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.

Conclusion

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.

8 thoughts on “Use SMTP4DEV for testing emails without sending in D365FO

  1. Nice post! Thank you very much for this information.
    How does that work with the configurable business documents in D365 and the use of ER reporting destinations?
    I mean if we setup the e-mail output not with print management but with ER reporting destinations.
    Is it the same behavior with the smtp4dev?
    I would hope so, but you are referring to “SSRS Email print destination but in this article, we will rather focus on the Email print destination improved by Docentric”

    1. Hi Jürgen,

      Configurable Business Documents are emailed using the same Email parameters as SSRS reports, so, yes, you can use smpt4dev with CBD too! The only requirement is to configure SMTP as Batch email provider in Email parameters.

      What Docentric adds to the built-in SMTP email provider is that you can use multiple SMTP sender accounts at the same time, which get chosen via the From field in the print setting (which isn’t available for SSRS and ER Email print destinations). You can even use third-party SMTP providers, which is important when you need to send more than 10K emails per day (Exchange Online Sending Limits).

      On the other hand, when using the built-in email providers (SMTP or Exchange), the From field of the outgoing email message is always set to the current user email.

      Please note that you can also use smpt4dev in UAT environments.

      Kind regards,
      Ana

  2. I have running Smtp4dev server on local PC. Everything looks ok, listening on port 587 web interface on localhost:5000 is ok. So I need to test emails send from Laravel 7 application which uses Swift mailer library but does not work. Still some error with ssl or with authentication.

    For example this is the error I get back

    Failed to authenticate on SMTP server with username “noreplay@tatrytec.eu” using 3 possible authenticators. Authenticator CRAM-MD5 returned Expected response code 235 but got code “535”, with message “535 5.7.0 Invalid login or password “. Authenticator LOGIN returned Expected response code 250 but got an empty response.

    Do you have some experience with using Laravel 7 and Smtp4dev? Thanks for any help. I am at the end.

    1. Hi Camo,

      Unfortunately, we don’t have experience with using smtp4Dev and Laravel 7. We have tested smtp4Dev with Dynamics 365 F&O .

      Best regards,
      Jovica.

  3. JFI. There are numerous SMTP servers and services for developers and debugging. Personally, I prefer using free web service https://mailtrap.io/. In this case, you don’t need to install anything.

    1. Yes, it’s true there is no installation and for email testing on a development environment/by a single user, the free version of Mailtrap would totally be a sufficient & simple solution.

      On the other hand, smtp4dev is completely free, the installation is super-easy, no limitations apply, and you have full control over it.

      In the end, choosing the right email testing tool certainly depends on your scenarios and preferences :). Thanks for sharing!

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 >>