Jump to content

EMAIL

From Commander4j
Revision as of 21:47, 9 November 2026 by Dgarratt (talk | contribs) (Updated by push_wiki.py)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The EMAIL connector sends a file as an email attachment. This page also describes email.xml, which holds the mail server settings and the distribution lists used for error and status emails from every map.

EMAIL Map Configuration

config.xml

      <map>
         <id>Map05</id>
         <enabled>true</enabled>
         <description>Send File via Email</description>
         <enableEmailNotifications>true</enableEmailNotifications>
         <connectors>
            <input>
               <id>in1</id>
               <description>Read File</description>
               <type>EMAIL</type>
               <url>
                  <path>./interface/input/Map05 File to EMAIL</path>
                  <mask/>
                  <prefix/>
                  <pollingInterval>1000</pollingInterval>
               </url>
            </input>
            <output>
               <id>out1</id>
               <enabled>true</enabled>
               <description>Email File</description>
               <type>EMAIL</type>
               <url>
                  <path>./interface/output/Map05 File to EMAIL</path>
                  <prefix/>
                  <fileExtension/>
                  <use83GUID>false</use83GUID>
               </url>
               <email>
                  <emailListID>Excel</emailListID>
                  <subject>Test Email</subject>
                  <message>See Attached File</message>
               </email>
            </output>
         </connectors>
      </map>

The email connector provides an automated method of sending files via email. It's currently a "send only" connector so it does not have the ability to check for incoming emails.

If we look at the example configuration above we can see that both the input and output types are defined as

 <type>EMAIL</type>

The way the system works is that you specify a folder and file type (mask) that you want to detect on the input connector side and the destination / subject / message on the output side. The file is moved from the input folder to the output folder and sent as an attachment. No style sheet is used.

If the mask is left empty, files ending in txt, xml, csv, idoc or pdf are picked up. For any other kind of file enter its extension as the mask.

The file is only sent when enableEmailNotifications is true both at the top of config.xml and on the map.

Rather than putting email addresses in the middleware config directly the output map lets you specify a distribution list

 <emailListID>PDF</emailListID>

The email addressed associated with the emailListID are held in the email.xml configuration file. This file is described below.

EMAIL Settings

email.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <emailSettings>
    <configuration>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.starttls.enable" value="true"/>
        <property name="mail.smtp.host" value="smtp.gmail.com"/>
        <property name="mail.smtp.socketFactory.port" value="465"/>
        <property name="mail.smtp.user" value="dummy@gmail.com"/>
        <property name="mail.smtp.password" value="mycomplexpassword"/>
        <property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory"/>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.port" value="465"/>
        <property name="mail.smtp.from" value="dummy@gmail.com"/>
    </configuration>
    <distributionList id="Monitor" enabled="Y" maxFrequencyMins="0">
        <toAddressList>dummy@gmail.com</toAddressList>
    </distributionList>
    <distributionList id="Error" enabled="Y" maxFrequencyMins="5">
        <toAddressList>dummy@gmail.com</toAddressList>
    </distributionList>
    <distributionList id="Excel" enabled="Y" maxFrequencyMins="5">
        <toAddressList>dummy@gmail.com</toAddressList>
    </distributionList>
    <distributionList id="PDF" enabled="Y" maxFrequencyMins="5">
        <toAddressList>dummy@gmail.com</toAddressList>
    </distributionList>
 </emailSettings>

You will see there are several distributionList entries above and you can create new ones if you want. Each section has the following attributes.

Some of these lists have a "standard" purpose and should not be deleted or renamed.

Monitor is used to send daily statistics on the number of messages processed. It will also email you to say if the Middleware service stops or starts.

Error - as it's name suggests will inform you of any errors encountered, such as a network share becoming unavailable.

Distribution List Settings

System Keys
Element Value Description
id id A identification which can be used in a mapping file. The email.xml can have multiple distribution lists but each one must have a unique id.
description string Meaningful description of what the distribution list is for.
enabled Y or N A simple way to disable or enable a list.
maxFrequencyMins nnn Number of minutes between identical emails. This can prevent or limit the number of emails which can be sent due to a persistent error condition.
toAddressList email Email addresses separated with a comma

Mail Server Settings

The <configuration> section holds the settings for the mail server. Only the section named exactly configuration is used. The file supplied with the program contains several examples named configuration0, configuration1 and so on; to use one of them, rename it to configuration and rename the current one to something else.

Each property can carry an encrypted attribute. To avoid storing the mail password in plain text, encrypt it with the EncryptString utility installed with Middleware4j (it saves the result in a file called password.txt), paste the result into the value, and set encrypted="yes" on that property.

 <property name="mail.smtp.password" encrypted="yes" value="...encrypted text..."/>

Example Email Settings

SMTP No Authentication Example

    <configuration>
        <property name="mail.smtp.starttls.enable" value="false"/>
        <property name="mail.smtp.host" value="smtp.demo.com"/>
        <property name="mail.smtp.socketFactory.port" value="25"/>
        <property name="mail.smtp.user" value="demo@email.com"/>
        <property name="mail.smtp.password" value=""/>
        <property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory"/>
        <property name="mail.smtp.auth" value="false"/>
        <property name="mail.smtp.port" value="25"/>
        <property name="mail.smtp.from" value="demo@email.com"/>
        <property name="mail.debug" value="true"/>
    </configuration>

Microsoft smtp.live.com Example

  
    <configuration0>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.starttls.enable" value="true"/>
        <property name="mail.smtp.host" value="smtp.live.com"/>
        <property name="mail.smtp.socketFactory.port" value="25"/>
        <property name="mail.smtp.user" value="email@outlook.com"/>
        <property name="mail.smtp.password" value="mycomplexpassword"/>
        <property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory"/>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.port" value="25"/>
        <property name="mail.smtp.from" value="email@outlook.com"/>
        <property name="mail.debug" value="true"/>
    </configuration0>

Google gmail Example

    <configuration1>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.starttls.enable" value="true"/>
        <property name="mail.smtp.host" value="smtp.gmail.com"/>
        <property name="mail.smtp.socketFactory.port" value="465"/>
        <property name="mail.smtp.user" value="email@gmail.com"/>
        <property name="mail.smtp.password" value="mycomplexpassword"/>
        <property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory"/>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.port" value="465"/>
        <property name="mail.smtp.from" value="email@gmail.com"/>
        <property name="mail.debug" value="true"/>
    </configuration1>

See also: Connectors, Maps