Professional Documents
Culture Documents
KG
Festo_SMTP.lib
Documentation of the library Festo_SMTP.lib for CoDeSys 2.3
staf
18.02.2010
2 Festo_SMTP.lib
Content
General ..................................................................................................................................................... 3
Architecture ............................................................................................................................................. 3
Conditions ................................................................................................................................................ 5
General
Festo_SMTP.lib is an internal CoDeSys 2.3 library. With this library it’s possible to send E-Mail’s via
simple mail transfer protocol.
Architecture
To send a message, you must save an instance of the function module SMTP_sendMail. The function
block on the other hand calls functions and function blocks until the mail is sent or an error occurred.
On failure, the output variable error contains the error message of the server.
The module uses the function SMTP_connect to establish a connection to the SMTP server, whose IP-
Address was passed at the entrance. If a connection could be established, the SMTP commands to the
server will be sent by the function module SMTP_sendBuf and evaluated each response from the
server via the function module SMTP_recvReply. The SMTP_close function closes the connection to
the server.
The following flowchart represents the calling hierarchy and functionality of SMTP_sendMail :
SMTP_connect()
Server connected? no
Establish connection to the specified
SMTP-Server
yes
SMTP_recvReply() SMTP_SendBuf()
Receive reply from Servers Send SMTP-command EHLO
yes SMTP_SendBuf()
Server need
Authentication ?
Send SMTP-command AUTH
no
SMTP_recvReply() SMTP_SendBuf()
Receive reply from Servers Send SMTP-command MAIL
SMTP_recvReply() SMTP_SendBuf()
Receive reply from Servers Send SMTP-command RCPT
SMTP_recvReply() SMTP_SendBuf()
Receive reply from Servers Send SMTP-command DATA
SMTP_recvReply() SMTP_SendBuf()
Receive reply from Servers Send SMTP-command QUIT
SMTP_recvReply()
Receive reply from Servers
Conditions
The function block SMTP_sendMail requires access to an SMTP server over TCP/IP (TCP port 25).
The IP address of the SMTP server must be known. The name of the server is not sufficient because
DNS is not supported by each controller.
The IP address of the SMTP server (if not known) can be determined, by pinging the server from the
PC.
Simply open the Windows command prompt and type the command ping with the SMTP server name:
It is usually necessary to log in to a SMTP-server with username and password to send mail’s through
the server. In local networks is not strictly necessary.
SMTP_sendMail supports the most common methods of PLAIN, LOGIN and CRAM-MD5.
Function/Functionblock Description
Function/Functionblock Description
Function/Functionblock Description
Initialize
An instance of the SMTP_sendMail function block must be created. A buffer for the content of the
mail has to create also. If you want to attach a file to the mail, the file must exist on the controller or
have to be created.
Example:
9 Festo_SMTP.lib