Example of Sending Email Notifications from NetPing Using Local SMTP Server in OS Windows

  • Published In: Tutorial
  • Created Date: 2015-08-14
  • Hits: 2514

NetPing devices for monitoring server rooms and remote controlling a power supply have got a possibility to send e-mail notifications about triggering sensors and relays, as well as send periodical reports about status of sensors according to previously configured schedule at the page of a web interface. However, the firmware of the module for sending e-mail notifications and reports of several devices is implemented to support the work with mail servers only, which support SMTP protocol, and an authentication method AUTH PLAIN. In addition, a module for sending e-mail notifications and reports cannot support SSL, TLS or other encoding types.

To avoid problems with sending e-mail notifications from devices NetPing through SMTP servers that work without authorization, or support an authentication method AUTH LOGIN and TLS encoding, it is possible to use a local SMTP relay from Microsoft. It is installed in server rooms under Windows OS in several minutes and requires a minimal configuration to start sending e-mail notifications.

As a result of using SMTP relay in server rooms under Windows OS, we have a working functionality for sending e-mail notifications from NetPing devices regardless features of the module sendmail, implemented in firmware of devices.

Requirements

To implement sending e-mail notifications through an SMTP relay from Microsoft, there is a need to have:

Configuring SMTP Relay in Windows OS

In this article, installing and configuring an SMTP relay on Windows Server 2012 R2 OS is described.

On default, Windows OS SMTP relay is not installed in server rooms. Firstly, there is a need to install an SMTP relay to implement sending e-mail notifications. To do this, there is a need to connect to a console of a server with an administrator's rights. Open a window «Server Manager» and choose a menu item «Add roles and features»:

Menu for adding a new role or configuration in Windows Server 2012

A window of settings «Add Roles and Features Wizard» will be opened. At the step named «Installation Type» select a checkbox «Role-based or feature-based installation», which configures roles and additional settings at this local server. Then click the button «Next >»:

Selecting the mode for installing roles and advanced settings on a local server in Windows Server 2012

At the step «Server Selection» select a checkbox «Select a server from the server pool» with an available pool and click the button «Next >»:

Select a server from the server pool Windows Server 2012

At the step «Features» choose «SMTP Server» out of a represented list by checking a corresponding checkbox:

Installing SMTP Server on Windows Server 2012

While checking the checkbox a window with a list of additional components will appear. These components must be installed for an SMTP relay to work fully and properly. There is a need to approve the list of additional components and click the button «Add Features»:

Additional components for installing SMTP relay in Windows Server 2012

The last step is to check components selected at the previous steps. If the preparation was completed properly, it is left to click the button «Install» and wait for the installation to complete.

SMTP relay is configured at the console «Internet Information Services (IIS) 6.0 Manager». To run a console, open a window «Server Manager». To do this, choose «Tools» > «Internet Information Services (IIS) 6.0 Manager» in the upper right menu:

Running Internet Information Services (IIS) 6.0 Manager in Windows Server 2012

SMTP relay is being configured in properties of a virtual server «SMTP Virtual Server #1» (any number of virtual servers can be created if necessary):

The SMTP relay configuration process is performed in the virtual server properties

In properties of SMTP relay at the tab «General», it is recommended to log operation events of a virtual server using a checkbox «Enable logging»:

SMTP relay - Enable logging

A button «Properties...» opens a window with additional settings of a log file, in the same window it is possible to configure the information, which will be displayed in a log file and choose a location to store log files.

In properties of an SMTP relay at the tab «Access», it is possible to configure several parameters: «Relay...» and «Authentication...».

SMTP relay at the tab Access

A function «Relay...» configures settings of destination IP addresses, emails will be sent. If no additional restrictions are necessary, there is a need to choose «All except the list below». This will allow to send emails to all addresses.

Configure IP addresses in SMTP relay, which will be allowed to send letters

The function «Authentication...» allows to configure authentication to the virtual server:

Configure authentication to this virtual server

In the window «Authentication», it is possible to choose using anonymous access to a server or configure a basic authentication with TLS encoding if necessary. To configure anonymous access is as simple as to check a checkbox «Anonymous access». If there is a need to configure a basic authentication, then besides checking a checkbox «Basic authentication» there is a need to add users, to whom it is allowed to send emails. To do this, there is a need to click the button «Add...» at the tab «Security» and add required users. In the example for sending e-mail notifications, an account «smtprelay» is added, which is created at the domain «TST». This account will be indicated in settings of the device NetPing at the page «E-MAIL» of a web interface. Sending email through an account of a system administrator will not necessarily work, hence it is desirable to add another user!

Adding a user to use basic authentication in SMTP relay from Microsoft

In properties of an SMTP relay at the tab «Delivery», a connection to an external email server is configured for sending e-mail notifications to specified destination addresses. There is a need to configure the next parameters: «Outbound Security...», «Outbound connections...» and «Advanced...».

SMTP relay settings for connecting to an external mail server for sending e-mail messages to the specified recipients

A parameter «Outbound Security...» allows setting an authentication method to connect an external SMTP server. Let us suppose there is a need to configure a basic authentication to a connected SMTP through the Internet. To do this, there is a need to check a checkbox «Basic authentication» and indicate a username and a password. A username and a password need to be received from the administrator of the server.

SMTP relay - configure the authentication method for connecting to an external SMTP server

A parameter «Outbound connections...» allows to set a necessary TCP-port for communication, for example, 2525:

SMTP relay - Configuring the TCP port to connect to an external mail server

A parameter «Advanced...» allows to register a full domain name (address, which is used in MX records) or an IP address of a remote SMTP server:

Configure the FQDN or IP address of the remote SMTP server

To check a correctness of an entered full domain name, there is a need to start checking by clicking «Check DNS». A successful result is followed by the next notification:

The domain name is valid - SMTP relay

Checking Operability of an SMTP Relay in Windows OS

1. To check an operability of an SMTP relay, there is a need to run a command line («Start» > «Run», enter a name of the executable file of the command line «cmd», click «OK») and enter a command, which allows to connect to an SMTP server via telnet:

telnet localhost 25

If a server service works correctly, then the next notification will appear in response to a command indicated above (i.e., connecting to an SMTP relay is established):

Connecting to SMTP relay via telnet

2. To check if an SMTP relay sends emails to a third party SMTP server, there is a need to create a text file with contents indicated below:

File for checking the sending of e-mail messages to a third-party SMTP server from SMTP relay

Copy the file to the folder via the next path: «C:\inetpub\mailroot\Pickup». If the file from the folder «Pickup» disappears after copying, and a message created before in a text file reaches its destination, then SMTP relay is in a completely working condition. 

Debugging SMTP Relay in Windows OS

If for some reason emails do not reach destination numbers, there is a need to check the next parameters:

1. If TCP-port 25 is opened in a firewall;

2. If the SMTP relay service of a server is launched;

3. If a third party SMTP server receives e-mails;

4. If an IP address of a server is in a spam list;

5. If web.config is properly entered. It must look like the following:

<system.net>
    <mailSettings>
            <smtp deliveryMethod="SpecifiedPickupDirectory"
                        from="write_e-mail">
                <specifiedPickupDirectory 
                                pickupDirectoryLocation="C:\inetpub\mailroot\Pickup" />
            </smtp>
        </mailSettings>
</system.net>

Configuring a NetPing Device for Sending E-mail Notifications

NetPing devices are configured in the simplest way. To do this, there is a need to connect to a device web interface or go to the page «E-MAIL» and fill in the next corresponding parameters:

Configuring a NetPing Device for Sending E-mail Notifications

where:
SMTP Server Address is a domain name or an IP address of a local SMTP relay in Windows OS.
SMTP Server TCP Port is a TCP port SMTP relay in Windows OS.
Username – is a user's account, which was added when configuring a basic authentication in properties of an SMTP relay (the tab «Security»).
Password – is a password for an account.
From – is an e-mail of a sender.
To – is an e-mail of a recipient.

Therefore, a method for sending e-mail notifications from NetPing devices through an intermediate SMTP relay described above allows maintenance staff to receive e-mail notifications and does not depend on an authentication method of an external SMTP server.


Tags: All devices
comments powered by Disqus