![background image](http://html.mh-extra.com/html/amx/dvx-21xxhd/dvx-21xxhd_webconsole-and-programming-manual_2937827111.webp)
Appendix B: SMTP Support
111
NetLinx Integrated Controllers (Firmware v4)- WebConsole & Programming Guide
Appendix B: SMTP Support
Overview
NetLinx Integrated Controllers (Masters) have built-in support for transmission or email via an SMTP server. NetLinx Master
support includes the configuration of a single outbound SMTP server and the subsequent transmission of individual emails via the
configured server.
SMTP Server Configuration
The SMTP Server is configured by specifying a set of server properties. SMTP server properties once set are persistent on the
master until they are reset to a different value. SMTP server properties include the server IP address or URL, the SMTP IP port
number for connecting to the server, any username and password that is required for connecting with the server, the "from"
address that will be associated with all outgoing messages and finally a flag indicating if the server must support TLS
authentication security in order to establish a connection. Properties are set and read using two built-in NetLinx functions:
SMTP_SERVER_CONFIG_SET(CONSTANT CHAR cfgName[], CONSTANT CHAR cfgValue[])
Sets a server configuration parameter. These configuration settings are general mail server settings and thus apply to all
emails. Settings are saved to the configuration database & thus are static upon reboot.
cfgName
is the server property name that is being set. Acceptable values are
ADDRESS
- SMTP server name, such as "mail.amx.com". The maximum number of characters allowed for email destination
is 127.
PORT
- SMTP server port, such as "25" or "0". 0 means "use the best default port" which would imply using 25 which is the
SMTP well-known port.
USERNAME
- Username to offer for authentication. If username length is set to 0, authentication is not attempted.
PASSWORD
- Password to offer for authentication. If password length is set to 0, authentication is still attempted but simply
uses a zero-length password.
FROM
- Mail address to populate to the 'Mail-From:' field in outgoing emails.
REQUIRE_TLS
- SMTP server must support TLS in order to establish a connection. Valid values are 'TRUE' or 'FALSE'
cfgValue
is the value to associate for a setting property.
char[] SMTP_SERVER_CONFIG_GET (CONSTANT CHAR cfgName[])
Queries a server configuration property. Returns the config property value.
cfgName
is the server property name that is being retrieved. Acceptable values are a subset of the settable properties
(username & password query are disabled as a security precaution). No return value
ADDRESS
- SMTP server name, such as "mail.amx.com". The maximum number of characters allowed for email destination
is 127.
PORT
- SMTP server port, such as "25" or "0". 0 means "use the best default port" which would imply using 25 which is the
SMTP well-known port.
'
FROM
- Mail address populated to the 'Mail-From:' field in outgoing emails.
REQUIRE_TLS
- SMTP server must support TLS in order to establish a connection. Valid values are 'TRUE' or 'FALSE'
The
NetLinx .axi
file has the following built in constants to ease configuration:
CHAR SMTP_ADDRESS[] = 'ADDRESS';
CHAR SMTP_PORT_NUMBER[] = 'PORT';
CHAR SMTP_USERNAME[] = 'USERNAME';
CHAR SMTP_PASSWORD[] = 'PASSWORD';
CHAR SMTP_REQUIRE_TLS[] = 'REQUIRE_TLS';
CHAR SMTP_FROM[] = 'FROM';
CHAR NULL_STR[] = '';
CHAR SMTP_TLS_TRUE[] = 'TRUE';
CHAR SMTP_TLS_FALSE[] = 'FALSE';
Example server configuration:
SMTP_SERVER_CONFIG_SET(SMTP_ADDRESS,'mail.mymailserver.com')
SMTP_SERVER_CONFIG_SET(SMTP_PORT_NUMBER,'25')
SMTP_SERVER_CONFIG_SET(SMTP_USERNAME,'myAccountUsername')
SMTP_SERVER_CONFIG_SET(SMTP_PASSWORD,'myAccountPassword')
SMTP_SERVER_CONFIG_SET(SMTP_REQUIRE_TLS, SMTP_TLS_TRUE)
SMTP_SERVER_CONFIG_SET(SMTP_FROM,'John Doe')