Setting Up TLServer Email Functions
1. Introduction
Before the Ethernet port was integrated into the newer Super PLCs such as the Nano-10, FMD and F-series, TRi PLCs could only use the TLServer as a TCP/IP gateway to perform network related functions, including sending of emails. For newer PLCs with built-in Ethernet, in many cases the PLC can be setup to send email directly without relying on the TLServer. However, TLServer can still be very useful as email helper in the following situations:
1) There is no Ethernet cable available to the PLC but the PLC are
networked via RS485 to a PC.
2) The PLCs are not permitted to make TCP connection directly to SMTP server residing
outside of the LAN.
3) The SMTP server requires authentication and/or encrpytion to send email that the PLC cannot handle
natively.
The following describe in details the several ways in which the TLServer can be used to help the PLC send out emails.
Email Method 1 - Using TLServer as Email Relay Server
Since version 3.20, the TLServer can be setup to work with SMTP servers that require authentication and encryption based on either startTLS or SSL/TLS. However, the default email function on the Nano-10, FMD and F-series PLCs does not support account authentication to communicate with the external SMTP server. If the PLC is connecting to the SMTP server provided by the ISP then in some cases authentication is not needed since the ISP will only allows connection from IP address that belongs to its subscribers.
However, most SMTP Servers now require both authentication and encryption. In such a case the simple <EMAIL> tag method described on the PLC's manual will not work since the PLC does not handle authentication with the SMTP server.
It is possible to program the PLC to handle unencrypted authentication with the SMTP server using complex TBASIC statements in order to send email (see examples described on the forum under "Frequently Asked Questions"). However, to simplify programming effort, we have introduced a new, "Email Relay Server" feature to TLServer starting from version 3.17 and improved with version 3.20. The "Email Relay Server" feature is for the TLServer to act as a pseudo, unauthenticated SMTP mail server to the PLCs and receive the email data from the PLC. It then in turn connects to an authenticated SMTP server and "relays" the email data to the actual SMTP server. In order to use this feature, the PLC would be configured such that its SMTP IP address is the IP address of the PC that is running the TLServer, and the SMTP port is that of the "Port # to Relay PLC Email".
The Email Relay Server can be any PC on your LAN that runs the TLServer that is already configured to work with an external SMTP mail server (whether autheticated or not). All PLCs on the same LAN can then send their email via this TLServer instead of directly to the external SMTP server. This could be advantages in terms of ease of programming and also should the company decide to change its ISP or SMTP server provider, only the TLServer needs to be re-configured and the PLCs on the network need not be configured individually to address the change.
Once the Email Relay Server is configured in both TLServer and the PLC, the standard way to send emails from the PLC using the PRINT#4 command and the <EMAIL> tag can be used directly as before. This is Email Method 2 described next.
Email Method 2 - Using TLServer as Email Slave
In this setup, the PLC connects to TLServer, which will monitor the data it receives via its serial port for a special <EMAIL> tag. This triggers a sequence of actions where TLServer receives the sender, recipient, subject and mail content via the serial port or Ethernet. When all the data has been received the TLServer will connect to the SMTP server and send out the email. For more details on this email method, please click here to go view File and Email Services.
NOTE: For Super PLCs with built in Ethernet, it is recommended to setup the TLServer as an Email Server Relay (method 1 above) so that the PLC does not need to be programmed to connect to TLServer and use the Email services.
Email Method 3 - Using TLServer as Email Master (Legacy)
The TLServer supports a legacy email feature (carried over since version 1.0) where the TLServer act as a master to a bunch of PLCs connected together via their RS485 port. TLServer can be configured to scan the internal variables of any of the up to 256 PLCs ID connected to it to determine if any of these PLCs has a request for the TLServer to send out email. If so the TLServer will then retrieve the email data from the relevant PLC, constructs a complete email and send it out. Click here for more details.
2. Configure, Test, and Operate SMTP EMail Server
NEW!: TLServer version 3.20 offers a slightly new look to the Email Setup, which has all the same features as before plus an option for encryption (select startTLS or SSL/TLS). The legacy method of sending Emails is also hidden by default, but can be accessed by selecting the "Use Lecacy Email Feature" box.
Configure
To setup the server to handle email requests, click on the "Setup Emails" button on the TLServer to open the following dialog box:
You can test your email configuration by clicking the button once you have entered all the correct settings. Once you click the "Email Test" button TLServer will initiate the sending of a test email using the Mail Server you specified. A new window will pop up, as shown below, that allows you to enter the recipient email address. Once you have typed the recipients email address, you can press enter to send a default email (can't be changed). If it works, you will see a message window that says the email has been sent, as shown below, and you will receive an email with the following content: "Test Message sent from TLServer" If some settings in the email configuration are not correct or you do not have a working Internet connection, you will see an error message.
Operate with PLC Super PLCs implement a list of "Network Services" (NS) commands similar to what you may have read in the TLServer (Files and Email Services). The Email NS command begins with a string enclosed within the angle bracket called a "tag", which is <EMAIL> in this case, and ends with a closing tag "</>". Depending on the command type, the PLC CPU may return one or more response strings via virtual comm. port #4, from which the PLC can read to determine if the NS command has been executed properly. The PLC can operate the Ethernet port by means of TBASIC INPUT$ and PRINT commands operating on COMM 4. It uses the PRINT #4 command to send out NS commands and the INPUT$(4) command to receive response data via the Ethernet port. E.g. To send data to an email address: whoever@yahoo.com with the subject "PLC Email Test", execute the following statements in a TBASIC custom function: PRINT #4 "<EMAIL whoever@yahoo.com>" ' change it to your own email. FOR I = 1 to 10000 Note:
SENDING EMAIL FAILS If you receive an error message instead of "<OK>" or the email is not delivered, then it could have been blocked by Java security or other antivirus/firewall software. Run TLServer with a Java Console (this can be done by running TLServer32.bat). You may get a prompt from Java security, Windows, or other Internet security management software asking if you want to block or allow the application and of course select allow for all network types. Check the debug option in TLServer-->Setup Emails (Refer to the end of the configuration section) Now try sending the email again and monitor the console for details. If the email is still blocked, then you may need to manually add TLServer to the allowed list for the software blocking it. Perform an Internet search for instructions on adding a program to the allowed list for the software in question since every security software has its own procedure. |