configuring microsoft dynamics ax 2012 alerts and email...

22
1 Configuring Microsoft Dynamics AX 2012 Alerts and Email Notifications Using an SMTP Email Relay Server with Office 365 With more AX Server machines being run in the cloud on Microsoft Azure we need a simple way to connect Dynamics AX 2012 to cloud hosted mail servers without the need to run Exchange server in the same Azure virtual network (vnet) as our Dynamics AX servers. Currently the demo images that Microsoft provides for download all rely on a dedicated VM (AX2012R2B) running Exchange Server to send email alerts and workflow messages. This is not a practical or a realistic current scenario with Dynamics AX servers running on Microsoft Azure. The Life Cycle Services demo image that gets generated does not even include a mail server image to distribute notification emails. Today with more clients running with Office 365 we need a way to connect our hosted AX servers to a cloud hosted email service. The challenge is that most cloud based email services running today require SSL or TLS secure encryption for authentication and unfortunately Dynamics AX 2012 does not support this additional authentication natively. There are a number of ways to customize Dynamics AX to support this additional secure authentication but it is much easier to use a Windows Server Simple Mail Transfer Protocol (SMTP) server as a relay. There are no additional costs to run an SMTP server as this is a feature included in Windows Server. This article will walk through the steps to configure the Windows Server 2012 R2 SMTP Feature to act as a relay to Office 365 as well as how to configure Dynamics AX mail settings to support this scenario. First consider where to install the SMTP service in your production environment. If you are using Workflow extensively you will have at least one dedicated workflow batch server. Depending on the volume of messages consider placing the SMTP service on this dedicated workflow batch server. Avoid installing the SMTP service on the production database server as a best practice. However for demo systems it works fine to include the SMTP service on the all in one server machine. For this article we will configure the SMTP service on a Dynamics AX2012 R3-CU8 demo image generated from Life Cycle Services. This article only covers email alert and workflow messages. Microsoft also now has integration with Exchange Server either on premise or on Office 365 for the Sales and Marketing module for Account/Contacts, tasks and calendar. This integration is available but not in the scope of this article. One more note about flooding SMTP messages from your server to the mail provider. You want to avoid any extremely large volumes of relay messages so you don’t get blacklisted. Just keep this in mind to avoid this situation. We will cover the following topics throughout this article: Installing the SMTP Server Configuring the SMTP Server o Testing SMTP Relay Messages o Troubleshooting SMTP eMail Sending Configuring Dynamics AX to use Windows SMTP Server Configuring Alert eMail Messages Testing Alert eMail Messages Using Gmail as an SMTP Mail Server

Upload: others

Post on 11-Jan-2020

26 views

Category:

Documents


1 download

TRANSCRIPT

1

Configuring Microsoft Dynamics AX 2012 Alerts and Email Notifications Using an SMTP Email Relay Server with Office 365

With more AX Server machines being run in the cloud on Microsoft Azure we need a simple way to connect Dynamics AX 2012 to cloud hosted mail servers without the need to run Exchange server in the same Azure virtual network (vnet) as our Dynamics AX servers. Currently the demo images that Microsoft provides for download all rely on a dedicated VM (AX2012R2B) running Exchange Server to send email alerts and workflow messages. This is not a practical or a realistic current scenario with Dynamics AX servers running on Microsoft Azure. The Life Cycle Services demo image that gets generated does not even include a mail server image to distribute notification emails. Today with more clients running with Office 365 we need a way to connect our hosted AX servers to a cloud hosted email service.

The challenge is that most cloud based email services running today require SSL or TLS secure encryption for authentication and unfortunately Dynamics AX 2012 does not support this additional authentication natively. There are a number of ways to customize Dynamics AX to support this additional secure authentication but it is much easier to use a Windows Server Simple Mail Transfer Protocol (SMTP) server as a relay. There are no additional costs to run an SMTP server as this is a feature included in Windows Server. This article will walk through the steps to configure the Windows Server 2012 R2 SMTP Feature to act as a relay to Office 365 as well as how to configure Dynamics AX mail settings to support this scenario.

First consider where to install the SMTP service in your production environment. If you are using Workflow extensively you will have at least one dedicated workflow batch server. Depending on the volume of messages consider placing the SMTP service on this dedicated workflow batch server. Avoid installing the SMTP service on the production database server as a best practice. However for demo systems it works fine to include the SMTP service on the all in one server machine. For this article we will configure the SMTP service on a Dynamics AX2012 R3-CU8 demo image generated from Life Cycle Services.

This article only covers email alert and workflow messages. Microsoft also now has integration with Exchange Server either on premise or on Office 365 for the Sales and Marketing module for Account/Contacts, tasks and calendar. This integration is available but not in the scope of this article.

One more note about flooding SMTP messages from your server to the mail provider. You want to avoid any extremely large volumes of relay messages so you don’t get blacklisted. Just keep this in mind to avoid this situation.

We will cover the following topics throughout this article:

Installing the SMTP Server

Configuring the SMTP Server o Testing SMTP Relay Messages o Troubleshooting SMTP eMail Sending

Configuring Dynamics AX to use Windows SMTP Server

Configuring Alert eMail Messages

Testing Alert eMail Messages

Using Gmail as an SMTP Mail Server

2

Conclusion

Dynamics AX servers running in the cloud on Azure can be easily configured to send mail notifications relaying from cloud hosted mail servers such as Office 365 and Gmail without the need to have a dedicated exchange server also running in the cloud. Using this simple configuration you can leverage cloud mail systems reducing the licensing and system machine costs required to run dedicated Exchange Servers in the same virtual location as Dynamics AX.

Dynamics AX 2012 Azure SMTP Server Relay

Azure Office 365 Outlook Client

Mes

sage

Flo

w

Windows SMTP Server

Outlook

Dynamics AX Server

Alert/Workflow Messages

Microsoft Azure Cloud, Office 365

3

Installing the SMTP Server

The first step is to add the SMTP feature to windows server from the server manager, Manage, Add Roles and Features. Then step through the wizard screens below to complete the installation process. This next process is driven from the following Microsoft technical article but shows step by step visuals of how this is done.

https://technet.microsoft.com/en-us/library/dn592151.aspx

4

Make sure IIS basic authentication is installed. It will most likely already be there especially on an AX demo image.

5

6

7

8

Configuring the SMTP Server

Once the installation wizard completes make sure the SMTP Service is started on the server before you being the next step. The easiest way to manage the SMTP Server is from the Server Manager Tools menu. Select Internet Information Server (IIS) 6.0 Manager.

9

10

11

12

Once all of these settings are completed re-start the SMTP Service.

13

Testing SMTP Relay Messages

You should always test the sending of SMTP messages through the relay before configuring Dynamics AX. This can help avoid confusion and difficulty in troubleshooting later on in the process. In order to test the sending of SMTP message first create a txt file in Notepad with the following information (using your own email addresses of course:

FROM: [email protected]

TO: [email protected]

SUBJECT: Test email

This is a test email sent from my SMTP server

Make sure that the FROM: address is the user that can authenticate on the remote mail server.

1) Drop the text file in the folder C:\inetpub\mailroot\Pickup

You will notice that the file almost immediately disappears since the SMTP service is monitoring this folder for entries. If all is working correctly you will receive a test message from your server sent via the SMTP relay.

14

Troubleshooting SMTP eMail Sending

Note the folders in the C:\inetpub\mailroot\ folder. You will use these to troubleshoot the service operation.

If you don’t get the message then check if there are any files in the C:\inetpub\mailroot\Badmail folder. This folder will have details of the issue. At first I did not have the messages using the authenticated Office 365 user and got a bounced message similar to below:

For this test from AX I used this bad message returned to confirm that the sending user in AX must be an authenticated user in Office 365.

15

Configuring Dynamics AX to use Windows SMTP Server

Now that we have messages successfully sending from the SMTP server sitting in Azure we can easily configure Dynamics AX to use this server to distribute mail messages. Since the SMTP server is running on the same virtual machine you only need to specify the current server name. You also need to specify a user that has access to the Local SMTP server. This user does not have to be a valid Office 365 user and should be local to the domain and machine that is running the SMTP service.

Configuring Alert eMail Messages

In order to test the alert email message we first have to configure alerts in Dynamics AX. You need a valid email template setup first. There is a sample alert message you can use similar to the below screen. Make sure that the Template sender address is a valid Office 365 user that can authenticate when sending the message.

16

Don’t forget to set a batch group on the general tab. This will be used when we launch the batch job to distribute alert email messages.

Next set the Alert template in the Alert parameters under Organization Administration, Setup, Alerts, and Alert parameters.

17

For the test just make sure you have a valid external email address in File, Tools, User Options.

Testing Alert eMail Messages

In order to test the alert rule email message sending let’s create an alert rule. Navigate to Accounts Receivable, Common, All Customers List Page. Edit a customer in the list. Right click the Customer credit limit field in the Credit and Collections fast tab and choose Create alert rule.

18

In our example we will create an alert rule every time the credit limit is changed. Create the Alert rule as follows and select to send e-mail.

Normally you would be running an alert processor batch job. For this simple test navigate to the AOT, forms and open the Tutorial_EventProcessor and click the start button. While running the label on the Start button will change to Stop.

Now let’s edit a customer credit limit and test the email sending. After you change the credit limit you get the processing window.

19

Within a few seconds you will see the Alert message from within the AX rich client.

In order to actually send the message we need to run the eMail Distributor batch job.

20

A few minutes later the message is sent to my regular company email account external to the local image. Success!

Using Gmail as an SMTP Mail Server

Let’s try the same thing using Gmail. We just have to make a few changes to our SMTP server configuration in order to make the same process work with Gmail.

http://www.uxceclipse.com.au/Pages/Blog-Detail.aspx?newslist=Blog%20List&itemId=69

21

22

Now go ahead and change the credit limit again. You will see the alert message from AX.

A few minutes later you will get the email alert message from the Gmail SMTP relay. Success again this time using Gmail as the mail relay server!