SoftPLC
 
Font size:      

Configuration Basics

Email Components

An email message as supported by this TLM is assembled from various parts. Listed below are the parts that the TLM needs or uses and the source of the part.


Parts of an Email Message According to SENDMAIL TLM
Part NameDescriptionSource
ControlA datatable CONTROL element consisting of 3 words. Used to keep track of the progress of the email.First TLI parameter
ResultA datatable STRING element that will hold explanatory text about the status of the send operation at completion. Second TLI parameter
IdentityA datatable STRING element which names a record in the SENDMAIL.LST file. The named file record will provide the SMTP server, SMTP account username and password, and Reverse-Path. Reverse-Path is a formal designation of the "From:" address.Third TLI parameter and the file /SoftPLC/tlm/SENDMAIL.LST
ToA datatable STRING element which holds a recipient list of email addresses, separated by a comma. No comma if only a single address. For example: "rbs@hme.com, another@hme.com" without the quotes.Fourth TLI parameter.
FileA datatable STRING element which holds the filename of the main body of the email message.Fifth TLI parameter and the named disk file. For example: "/home/root/mainbody.txt"
AttachmentA datatable STRING element which holds the filename of the attachment to the email message. An empty STRING is interpreted as no attachment.Sixth TLI parameter and the named disk file. For example: "/tmp/processdata.csv" without the quotes.
File MIME TypeA formal textual description of the MIME type for the File of the email message. If not provided, then "text/plain" is supplied automatically. A valid alternative would be "text/html" if your main body file is HTML. Not required, but can be given preceeding the filename in the fifth TLI parameter. For example: "text/plain: /etc/NETWORK.LST" without the quotes. The colon-space combo is the separator, and will be stripped away when grabbing the MIME type and filename.
Attachment MIME TypeA formal textual description of the MIME type for the Attachment of the email message. If the type is "application/octet-stream" or any other starting with "application/", then the attachment will be base64 encoded such that a binary attachment will be sent exactly. If not provided, then "application/octet-stream" is supplied automatically. A valid alternative would be "text/plain".Not required, but can be given preceeding the attachment in the sixth TLI parameter. For example: "application/octet-stream: /tmp/mydata.zip". The colon-space combo is the separator, and will be stripped away when grabbing the MIME type and attachment.

Sample Main Body Files

The main body file must be a text disk file, either simple ASCII or HTML.

Attachment Files

The single allowed attachment may be a text or binary disk file.

SENDMAIL.LST Configuration File

The configuration file for the SENDMAIL TLM is /SoftPLC/tlm/SENDMAIL.LST, and a sample is shown below.

Sample SENDMAIL.LST
# Configuration file for SoftPLC SENDMAIL TLM.
# Anything from # to end of line is a comment.

# The debug parameter comes first, set to 0 to turn off debugging.  Bits within
# debug are as follows, use 3 to turn on both bits.
#define DEBUG_SHOW_ARGS         (1 << 0)    // print the TLI arguments
#define DEBUG_TRANSACTIONS      (1 << 1)    // print stuff from mail server

debug = 3
#debug = 0

# Next comes one or more identities.  An identity consists of
# identity = name
# and a number of trailing attribute/value pairs that follow on separate lines.
# The identity name must match your TLI "Identity" ladder instruction parameter.
# Then comes server, reverse_path, and optionally: username, password,
# starttls, helo.

#########################################################################
identity = plc42
    # server: set to the name and port number of the SMTP server. Be sure and
    # provide the port number, either 25 or 587 after the server name.
    server = mailserver.birch.net:25

    # reverse_path: is tantamount to the "From:" email header, but is called
    # reverse_path because of RFC 2821. Think of this as a from field for the
    # email.
    reverse_path = plc42@softplc.com

    # helo: set the hostname to be identify as when sending HELO or EHLO commands.
    # This is a per identity option.  It should be the name you are seen as
    # from the answering server.  If none given, then this machine's hostname
    # is used (and that is usually sufficent).
    helo     = plc42

    # username = dick@softplc.com
    # password = not_needed_because_T1

    starttls = disabled

#########################################################################
identity = info@softplc.com
    server = smtp.gmail.com:587
    # helo     = plc42
    username = gmailuser@gmail.com
    password = wordclue
    starttls = required
    reverse_path = gmailuser@softplcc.com

From the sample configuration file above, you can see that after the debug setting, then comes the identity record(s). You only need one identity record if you only plan on using only one SMTP account. You may omit the 2nd identity record. The comments in the sample file should be enough to get you going.