Introduction
Sending emails using a PLC is a big foot in the control automation world: lots of people have heard about it but rarely anyone has ever seen it. In this article, I’ll demonstrate the process to send emails with a PLC.
In my demonstration, I’m doing the entire process through the internet using publicly available services. Implementing a similar function in an intranet environment may be different.
How It Works
In order to send email with a PLC, you need to have a SMTP (Simple Mail Transfer Protocol) server. Your PLC must be able to access the SMTP server and the SMTP server must be able to deliver your email to your recipients’ email server.
The below picture describes the working process for a PLC to send an email to a recipient. The PLC sends an email to the SMTP server and the SMTP server delivers the email to the recipient’s email server via the internet. And the recipient receives the email from the email client.

By default, the recipient side is ready since we all have email accounts to receive emails. The part that we need to do is setting up the SMTP server and get the PLC to do the job.
Below are the steps to do so.
Skipped Part: Register A Domain
You will need a domain to run the SMTP server if you want to send the email through the internet. You may not need it if you just want to send emails through your intranet that has a SMTP server available.
Since registering a domain is remotely related to the topic this article focuses on, I will skip this part.
Configure the SMTP Server
I’m using SMTP2GO’s free tier service for demonstration. There are many other SMTP service providers and I’m not recommending anyone’s service.
After registering an account in SMTP2GO, I need to add a verified sender with my personal domain. My website is also hosted under this domain.

Adding a verified sender allows me to send emails with any sender name and domain name which looks nice. You don’t have to do this if your SMTP service provider doesn’t require you to do so.
There are a few steps to add the SMTP server’s DNS records to your domain hoster. Since this part is simple and involves too much private information, I will skip the details.
PLC Configuration and Programming
Finally we are talking about the PLC work.
Hardware Configuration
Since I’m using a SMTP server on the internet, my PLC needs to have internet access as well and I have made it happen (simple stuff).

To let my PLC work properly with domains, I need to give it a DNS. Here I’m using Cloudflare DNS.

Also, to make sure the internet related functions are all working properly, I need to give it a NTP server. Here I’m using the NTP service from Microsoft.

Hardware configuration is done.
Program the Email Client
Sending email with S7-1500 (and S7-1200 as well) is achieved software wise with a SIEMENS system function TMAIL_C. This command encapsulates all the necessary system commands like TCON, TSend, TRCV, TDISC, etc.
The TMAIL_C function block call is simple.

The block call asks for the information just like an email client.
The most important part of the TMAIL_C function block call is the MAIL_ADDR_PARAM. Among the information the data structure requires, I’ll explain the ones that may be confusing.
The InterfaceID is the hardware ID of the network interface that the PLC uses to communicate with the SMTP server.

The ID can be any number as long as it is unique.
The connection type is set to 16#16 according to the comment and because I’m using TMail_FQDN (Addressing by fully qualified domain name).
The MailServerQDN is given by SMTP2GO. The username and password are generated when I add the verified sender.
The From information will become the sender’s email address.
The remote port is also given by SMTP2GO.
Since I’m not using a secured connection (for test only), I’m leaving the last 3 parameters as default.

The programming part is done nice and easy.
Send the Email
After finishing the hardware configuration and the programming, simply download the project to the PLC and toggle the TMAIL_C’s req input to send the email.
Below is the email that I have prepared and sent to my contact email address.

And below is the email that I have received.

Conclusion
This article demonstrates how to configure the SMTP server and configure and program the S7-1500 PLC to send email through the internet to any recipient. A similar procedure can allow the PLC to send emails in an intranet environment.
Sending such emails with just the PLC and the necessary network infrastructure provides an alternative to monitor the automation systems and it provides limitless potential usages.