Topic: P142

Send Email (EMAL) Instruction

Mnemonic (Keyboard Shortcut) = EMAL

Icon / Button =

Purpose

Send either a standard SMTP or TLS email with text and/or embedded data to Email recipient(s) via the CPU Ethernet Port. A TLS Mail Account can also send an attachment and/or log files which can be the latest file stored in the USB or Micro SD memory device.

 

Mail Account option requires the use of a predefined Mail Account that was created in the Hardware Configuration. The SMTP Client device will specify the SMTP server's TCP/IP address information and user account authentication (if required).

Instruction Parameters

 

Parameter

Parameter Type

Requirements

Description

Enable

Ladder Input

Must Have

Edge-driven.  When Enable is ON, the instruction will operate for one scan.

Mail Account

Dropdown

Optional

A Mail Account must be created in the Hardware Configuration for this instruction. Once a Mail Account has been created, it can be selected in this field.

SMTP Server IP Address

Constant

Optional

The IP Address of the Email server that the message will be sent to. The IP Address Must Have periods separating the octets.

From

String / Constant

Must Have

The Email Address of the Sender, to be displayed in the From field.

Subject

String / Constant

Must Have

The Text to be displayed in the Subject field of the Email.

Message

String / Constant

Must Have

The Message that will be sent in the text body of the Email. If not using a constant then use the Pack String (PKS) instruction to build your message.

Attach Event and Error Files

Checkbox

Optional

A copy of the CPU error and event history will be attached to the Email. *See Note 1

Attach Log File

Checkbox

Optional

A copy of the most recent log file will be attached to the Email. *See Note 1

Destination Email Address

String / Constant

Must Have

The Email Address to send the Message to.

Structure

Checkbox

Optional

Enable the use of Structure.

In Progress

Boolean Tag

Optional

Status Bit that specifies a request is in progress inside of the CPU (sent from the instruction but not yet sent out the Ethernet Port). The Status Bit reflects the status of the individual request. *See Note 1

Sent

Boolean Tag

Optional

The Mail Sent bit is turned ON once the instruction has completed successfully. This bit will reset whenever the instruction is enabled in the ladder.

Success

Boolean Tag

Optional

Status bit that specifies a request has been sent and a reply has been received, but it may not necessarily have been a good reply. The Status bit reflects the status of the individual request. *See Note 1

Error

Boolean Tag

Optional

Status bit the Email has been sent and a reply with an Error has been received from the Email Server. Check the Error Response String to determine the failure. The Status bit reflects the status of the individual request. *See Note 1

Error Response

String

Optional

String that holds the Error response. *See Note 1

   

Note 1: Only available when Mail Account option is selected.


Note 2: The Send Email instruction uses the External Ethernet Port configured in the Hardware Configuration.  See more details in the Communications topic.
Note 3: Only one valid e-mail address is allowed per string tag for the from & destination fields.
Note 4: Depending on your mail server an exception error may occur if the From address is different than Mail Account credentials.
Note 5: If attach error & event or Log file options are selected. Ensure a Portable Memory device is inserted & the files do exist or an error will occur.
Note 6: You may have to enable the ability to allow less secure applications setting on your email server account.
Note 7: Ensure CPU date & time is within 2 weeks of current if using a CA certificate in your mail account configuration or you may receive a "TLS handshake" error.


Send a Text Message via Email

Reference your cell provider for additional details on the ability to send an email-to-text service that will allow standard text messages to be generated and then sent to a specified cell phone number instead of an email account. This is a quick and easy way to test your SMTP Client settings from a P Series CPU to your cell phone. For example: AT&T customers tendigitcellnumber@txt.att.net

 

Instruction Configuration

When Send Email Instruction is selected the window shown below opens with defaults shown.

 

 

 

Parameter Configuration Table

Module Setup

Notes

Mail Account

 

                 

Choose Email Account Server setup in Hardware Configuration window.

SMTP Server IP Address

 

 

 

 

 

 

 

 

 

Enter the IP Address of the Email Server. SMTP, by default, only uses Port 25. If the mail server requires encryption and the 'SMTP Server IP Address' field is used, the EMAL instruction will silently fail.”

From

 

 

 

 

 

 

 

 

Enter the Email Address of the Sender. If using a Constant Data Type, quotation marks must be used at the beginning and end of the email address.

Subject

 

 

 

 

 

 

 

 

Enter the Subject of the Message. If using a Constant Data Type, quotation marks MUST be inserted at the beginning and end of the text.

Message

 

 

 

 

 

 

 

 

Enter the Message to be sent. If using a Constant Data Type, quotation marks MUST be inserted at the beginning and end of the text.

Attach Error/Event Files

                   

Select if attachment of Error/Event Files is needed.

Attach Log Files

                   

Select if attachment of Log Files is needed.

Destination Email Addresses

 

 

 

 

 

 

 

 

Enter Email Address(es) of Recipient(s). If using a Constant Data Type, quotation marks must be used at the beginning and end of the email address.

Use Structure

                   

Select if Structures are used.

In Progress

                 

Select a Boolean Tag for In Progress.

Complete

                 

Select a Boolean Tag for Complete.

Success

 

 

 

 

 

 

 

 

 

Select a Boolean Tag for Success.

Error

                 

Select a Boolean Tag for Error.

Exception Response

                 

Select a String Tag for Response Errors.

 

Application Example

Send Email Instruction allows a pre-typed Message and CPU Tagname Value to be Emailed from the CPU module through your SMTP server.  This is essentially the same as is done on most network printers.

Rung Example

SMTP

TLS

Error Response Table

General

Error Message

Possible Cause

Possible Solution

Error in From Address

The "From" tag was left blank.

Populate the "From" tag with a valid string or enter a constant in the EMAL instruction parameter.

Error in Destination Address

A "Destination Email Address" tag was left blank.

Populate the "Destination Email Address" tag with a valid string or enter a constant in the EMAL instruction parameter.

288 Can't connect to server

No DNS server settings

Add a preferred DNS IP address. An optional alternate DNS address server IP address can be entered.

Server Specific

AOL

Error Message

Possible Cause

Possible Solution

550 Request failed; Mailbox unavailable

Invalid Sender Address in EMAL instruction.

Ensure that the sender address is correctly entered and free of typos. You can verify the sender address by logging in to your email account online.

535 5.7.1 Authentication failed

Invalid User Name or Password is in the Mail Account properties.

Under Hardware Configuration > Mail Accounts: Open the AOL widget to show Properties and enter a valid User Name and User Password.

 

GMAIL

Error Message

Possible Cause

Possible Solution

535-5.7.8 Username and Password not accepted

Invalid User Name or Password is in the Mail Account properties.

Under Hardware Configuration > Mail Accounts: Open the Gmail widget to show Properties and enter a valid User Name and User Password.

 

OUTLOOK

Error Message

Possible Cause

Possible Solution

535 5.7.3 Authentication unsuccessful

Invalid User Name or Password is in the Mail Account properties.

Under Hardware Configuration > Mail Accounts: Open the Outlook widget to show Properties and enter a valid User Name and User Password.

554 5.2.0 STOREDRV.Submission.Exception. SendAsDeniedException

Outlook Server has identified the Client device as a possible SPAM generator and may have locked the account.

The user will have to take the steps to unlock their account. Afterwards, reduce the frequency of triggered EMAL instructions.

 

YAHOO

Error Message

Possible Cause

Possible Solution

550 Request failed; Mailbox unavailable

Invalid Sender Address in EMAL instruction.

Ensure that the sender address is entered correctly and free of typos. You can verify the sender address by logging in to your email account online.

535 5.7.1 Authentication failed

Invalid User Name or Password is in the Mail Account properties.

Under Hardware Configuration > Mail Accounts: Open the Yahoo widget to show Properties and enter a valid User Name and User Password.

535 Authorization failed

Invalid User Name or Password is in the Mail Account properties.

Under Hardware Configuration > Mail Accounts: Open the Yahoo widget to show Properties and enter a valid User Name and User Password.