How to send emails from HMI?
What to know
In JMobile it's possible to configure the project to send email messages using the "SendEmail" action.
System support also Live Tags, so it's possible to add to the message body the current value of a Tag.
What to do
The e-mail sending functionality is available into the system as an action called SendEmail that can be programmed at any Event.
Two properties are required to setup the SendEmail action:
- EmailConfig
- EmailInfo
EmailConfig
This property allow to configure the server used to send the e-mail:
- SMTP address: SMTP server address.
NOTE: if your are planning to use a hostname (like "smtp.gmail.com") instead of IP Address (like
"123.456.789.123"),
ensure your HMI have Network Settings: Name Server (DNS) and Default Gateway properly configured for
Internet Access - Server Port: SMTP port number of the server.
- Requires authentication: specifies if SMTP server requires authentication.
- User name: User name to be provided if authentication is required by the SMTP server.
- Password: Password to be provided if authentication is required by the SMTP server.
- Encryption: Encryption type to be used. NOTE: SSL authentication is supported starting from JM version
1.91 SP1
NOTE: More than one email server can be configured. Once configured the server will remain available in case another SendEmail action needs to be programmed.
EmailInfo
This property allows to configure the email message itself:
- Name: (optional) it can be used for information purposes.
- Description: (optional) it can be used for information purposes.
- From: Sender email address (ex. John@domain.com), can be connected to a string Tag
to manage the content in runtime. - To: Recipient email address. More Addresses can be specified by separating each
address using a semi-colon " ; "
can be connected to string a Tag to manage the content in runtime. - Subject: Subject of the email, can be connected to a stringTag to manage the
content in runtime. - Attachment: gives the possibility to provide the path of a file to be send as
attachment of the e-mail.
The system support one single attachment for each e-mail message sent.
NOTE: SMTP servers usually limit the max size allowed for an email attachment. - Message: Main content of the email. System support Live Tags, it's possible to add
to the message body the current value of one or more tags by specifying the Tag name between square
brackets like [Tag1] as shown in the image below. The body can be connected to a string Tag to manage
the content in runtime.
NOTE: more than one e-mail messages can be configured, once configured the e-mail will remain available in case another SendEmail action needs to be programmed.
Appendix: SSL vs TSL authentication
Secure Sockets Layer (SSL) and its successorTransport Layer Security (TLS), are cryptographic protocols that provide communications security over a computer network.
Always more frequently, public email server require to use SSL or TSL to authenticate.
With JMobile is possible to configure a project to sent email with username and password encrypted via SSL since JMobile v1.91, but TSL is still not supported.
Usually SSL authentication require use of port 465 and is required, for example, by following email server: Google, Yahoo, AT&T, Hotmail, Verizon, Mail.com
TSL authentication, that is not supported by JMobile, usually uses port 587, and is required for example by following email server:Outlook.com, Office365, T-Online, 1&1.