Last updated: June 20, 2015
Installation and Configuration
Using Telnet to Debug Mail Server Problems
Note: The Email service supports the basic Internet email transmission protocol, SMTP (Simple Mail Transfer Protocol) which supports only 7-bit ASCII characters. So, non-ASCII text (e.g. non-English characters) cannot be correctly represented in the message body or in the subject of an email sent via the Email service.
SERVICE <EmailName> LIBRARY JSTAF EXECUTE <Service Jar File Name> \ PARMS "MAILSERVER <mailserver> [PORT <mailport>] \ [SOCKETTIMEOUT <Number>[s|m|h|d|w]] \ [BACKUPMAILSERVERS \"<Space-separated list of mail servers>\"] \ [CONTENTTYPE <contenttype>] \ [RESOLVEMESSAGE | NORESOLVEMESSAGE]"where:
SERVICE email LIBRARY JSTAF EXECUTE c:/staf/services/email/STAFEmail.jar \ PARMS "MAILSERVER na.relay.ibm.com BACKUPMAILSERVERS na.relay.ibm.com" SERVICE email LIBRARY JSTAF EXECUTE c:/staf/services/email/STAFEmail.jar \ PARMS "MAILSERVER na.relay.ibm.com BACKUPMAILSERVERS \"na.relay.ibm.com la.relay.ibm.com emea.relay.ibm.com\"" SERVICE email LIBRARY JSTAF EXECUTE /usr/local/staf/services/email/STAFEmail.jar \ PARMS "MAILSERVER na.relay.ibm.com BACKUPMAILSERVERS na.relay.ibm.com \ PORT 25 SOCKETTIMEOUT 30s CONTENTTYPE text/html" SERVICE email LIBRARY JSTAF EXECUTE c:/staf/services/email/STAFEmail.jar \ PARMS "MAILSERVER na.relay.ibm.com BACKUPMAILSERVERS na.relay.ibm.com \ SOCKETTIMEOUT 2m NORESOLVEMESSAGE"
SEND < TO <Address> | CC <Address> | BCC <Address> >... [FROM <user@company.com>] [CONTENTTYPE <contenttype>] < MESSAGE <Message> | FILE <File> [MACHINE Machine] > [SUBJECT <subject>] [NOHEADER] [TEXTATTACHMENT <file>]... [BINARYATTACHMENT <file>]... [ATTACHMENTMACHINE <machine>] [RESOLVEMESSAGE | NORESOLVEMESSAGE] [AUTHUSER <User> AUTHPASSWORD <Password>]
TO specifies an email address to which the email will be sent. You may specify multiple TO options. This option will resolve variables. You can specify any number or combination of the TO, CC, and BCC options, but you must specify at least one of these options.
CC specifies an email address to which the email will be carbon copied. You may specify multiple CC options. This option will resolve variables. You can specify any number or combination of the TO, CC, and BCC options, but you must specify at least one of these options.
BCC specifies an email address to which the email will be blind carbon copied. You may specify multiple BCC options. This option will resolve variables. You can specify any number or combination of the TO, CC, and BCC options, but you must specify at least one of these options.
FROM specifies an email address that the email will be sent from. If this option is not specified, the default from address will be STAFEmailService@<host name> where <host name> is replaced with the host name of the machine where the Email service that is sending the message is registered. This option will resolve variables.
CONTENTTYPE specifies the content type to be used for the message body. The valid values are "text/plain" and "text/html". This parameter is optional. The default will be to use the current operational setting (either the value set during the Email service registration, or via the SET request).
MESSAGE specifies the body of the email. This option will resolve variables.
FILE specifies the file which contains the body of the email. This option will resolve variables.
MACHINE is the machine where the FILE is located. If not specified, it assumes the file is on the machine submitting the EMAIL SEND request. This option will resolve variables.
SUBJECT specifies subject of the email and is optional. This option will resolve variables.
NOHEADER indicates that the "DO NOT RESPOND TO THE SERVICE MACHINE THAT GENERATED THIS NOTE" header should not be included at the beginning of the email body. If this option is not specified, the header will be included at the beginning of the email body
TEXTATTACHMENT specifies a text file to attach to the email and is optional. You may specify multiple TEXTATTACHMENT options. This option will resolve variables.
BINARYATTACHMENT specifies a binary file to attach to the email and is optional. You may specify multiple BINARYATTACHMENT options. This option will resolve variables.
ATTACHMENTMACHINE is the machine where the attachments (if any) are located. If not specified, it assumes the files are on the machine submitting the EMAIL SEND request. This option will resolve variables.
RESOLVEMESSAGE | NORESOLVEMESSAGE specifies whether to resolve the MESSAGE option for STAF variables. If neither option is specified, the setting specified in the service parameters will be used.
AUTHUSER specifies the user name which will be used to authenticate with the SMTP server via the Auth Login SMTP command. You should only specify this option if your SMTP server requires authentication. If you specify this option when using an SMTP server that does not allow authentication, you will see an error message such as AUTH mechanism LOGIN not available. If you specify the AUTHUSER option, you must also specify the AUTHPASSWORD option. This option will resolve variables.
AUTHPASSWORD specifies the password which will be used to authenticate with the SMTP server via the Auth Login SMTP command. You should only specify this option if your SMTP server requires authentication. If you specify this option when using an SMTP server that does not allow authentication, you will see an error message such as AUTH mechanism LOGIN not available. If you specify the AUTHPASSWORD option, you must also specify the AUTHUSER option. This option will handle private data. This option will resolve variables.
STAF local EMAIL SEND TO user1@us.ibm.com message "Test XYZ completed successfully." SUBJECT "Test XYX: Success"
STAF local EMAIL SEND TO user99@company.com message "Testcase aborted with error code 5312." SUBJECT "Testcase aborted" AUTHUSER johnsmith@mail.com AUTHPASSWORD !!@secretPassword@!!
STAF local EMAIL SEND TO user1@us.ibm.com CC user22@us.ibm.com CC user104@us.ibm.com message "Test ABC completed successfully. { rc : 0, testResult : fail=0, pass=329 }" SUBJECT "Test ABC Results" NORESOLVEMESSAGE
STAF local EMAIL SEND TO user1@us.ibm.com TO user2@us.ibm.com message "Hello, this is the new STAFEmail Service\n\nThanks" SUBJECT "Introducing the new STAFEmail Service"
STAF server1.company.com EMAIL SEND BCC user3@us.ibm.com BCC user54@us.ibm.com FILE c:/results/testoutput.txt
STAF local EMAIL SEND TO user5@us.ibm.com message "SVT completed successfully. Details are attached." SUBJECT "SVT: Success" TEXTATTACHMENT c:/output/SVTTests.txt
STAF local EMAIL SEND TO user6@us.ibm.com message "Here are the test results" SUBJECT "Test Results" TEXTATTACHMENT G:/projects/test/Results.html BINARYATTACHMENT G:/projects/test/DetailedResults.zip ATTACHMENTMACHINE server1.company.com
STAF server1.company.com EMAIL SEND TO user3@us.ibm.com FILE c:/results/testoutput.html CONTENTTYPE text/html
STAF local EMAIL SEND TO user90@us.ibm.com MESSAGE "<h4>Test results:</h4><table border="1"><tr><th>Name</th><th>Passes</th><th>Fails</th></tr><tr><td>Function test</td><td>509</td><td>90</td></tr><tr><td>SVT regression</td><td>154</td><td>21</td></tr><tr><td>Globalization tests</td><td>67</td><td>4</td></tr></table>" CONTENTTYPE text/html SUBJECT "Overnight testing results"
STAF local EMAIL SEND TO user90@us.ibm.com CONTENTTYPE text/html NOHEADER SUBJECT "Test Results" message "<table border="0"><tr bgcolor=4477BB><td><font face="Arial,Helvetica">Name</td><td><font face="Arial,Helvetica">Passes</td><td><font face="Arial,Helvetica">Fails</td></tr><tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Function abcd</td><td><font face="Arial,Helvetica">509</td><td><font face="Arial,Helvetica">90</td></tr><tr bgcolor=99CCFF><td><font face="Arial,Helvetica">SVT regression</td><td><font face="Arial,Helvetica">154</td><td>21</td></tr><tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Globalization test5</td><td><font face="Arial,Helvetica">67</td><td><font face="Arial,Helvetica">4</td></tr><tr bgcolor=99CCFF><td><font face="Arial,Helvetica">Media testA</td><td><font face="Arial,Helvetica">90</td><td><font face="Arial,Helvetica">0</td></tr><tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Function fghi</td><td><font face="Arial,Helvetica">177</td><td><font face="Arial,Helvetica">34</td></tr><tr bgcolor=99CCFF><td><font face="Arial,Helvetica">TVT regression</td><td><font face="Arial,Helvetica">109</td><td>17</td></tr><tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Globalization test7</td><td><font face="Arial,Helvetica">11</td><td><font face="Arial,Helvetica">6</td></tr><tr bgcolor=99CCFF><td><font face="Arial,Helvetica">Media testB</td><td><font face="Arial,Helvetica">89</td><td><font face="Arial,Helvetica">1</td></tr></table>"
STAF local EMAIL SEND TO user90@us.ibm.com CONTENTTYPE text/html NOHEADER SUBJECT "Test Results" message "<table border="0">\n<tr bgcolor=4477BB><td><font face="Arial,Helvetica">Name</td><td><font face="Arial,Helvetica">Passes</td><td><font face="Arial,Helvetica">Fails</td></tr>\n<tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Function abcd</td><td><font face="Arial,Helvetica">509</td><td><font face="Arial,Helvetica">90</td></tr>\n<tr bgcolor=99CCFF><td><font face="Arial,Helvetica">SVT regression</td><td><font face="Arial,Helvetica">154</td><td>21</td></tr>\n<tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Globalization test5</td><td><font face="Arial,Helvetica">67</td><td><font face="Arial,Helvetica">4</td></tr>\n<tr bgcolor=99CCFF><td><font face="Arial,Helvetica">Media testA</td><td><font face="Arial,Helvetica">90</td><td><font face="Arial,Helvetica">0</td></tr>\n<tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Function fghi</td><td><font face="Arial,Helvetica">177</td><td><font face="Arial,Helvetica">34</td></tr>\n<tr bgcolor=99CCFF><td><font face="Arial,Helvetica">TVT regression</td><td><font face="Arial,Helvetica">109</td><td>17</td></tr>\n<tr bgcolor=DDEEFF><td><font face="Arial,Helvetica">Globalization test7</td><td><font face="Arial,Helvetica">11</td><td><font face="Arial,Helvetica">6</td></tr>\n<tr bgcolor=99CCFF><td><font face="Arial,Helvetica">Media testB</td><td><font face="Arial,Helvetica">89</td><td><font face="Arial,Helvetica">1</td></tr></table>"
LIST SETTINGS
Definition of map class STAF/Service/Email/Settings | |||
---|---|---|---|
Description: This map class represents the settings for the Email service. | |||
Key Name | Display Name | Type | Format / Value |
mailServer | Mail Server | <String> | |
port | Port | <String> | |
socketTimeout | Socket Timeout | <String> | |
backupMailServers | Backup Mail Servers | <List> of <String> | |
contentType | Content Type | <String> | |
resolveMessage | Resolve Message | <String> | Enabled | Disabled |
Notes:
|
STAF server1.company.com EMAIL LIST SETTINGS
Output: If the request is submitted from the command line, the result could look like:
{ Mail Server : NA.relay.ibm.com Port : 25 Socket Timeout : 60000 Backup Mail Servers: [ LA.relay.ibm.com EMEA.relay.ibm.com AP.relay.ibm.com ] Content Type : text/plain Resolve Message : Enabled }
SET [MAILSERVER <mailserver>] [PORT <mailport>] [SOCKETTIMEOUT <Number>[s|m|h|d|w]] [BACKUPMAILSERVERS <Space-separated list of backup mailservers>] [CONTENTTYPE <contenttype>] [RESOLVEMESSAGE | NORESOLVEMESSAGE]See "Installation and Configuration" for descriptions of these operational settings.
STAF server1.company.com EMAIL SET MAILSERVER mymailserver.company.com
STAF server1.company.com EMAIL SET CONTENTTYPE text/html
STAF server1.company.com EMAIL SET BACKUPSERVERS "mailserver1.company.com mailserver2.company.com"
STAF server1.company.com EMAIL SET SOCKETTIMEOUT 30s
STAF server1.company.com EMAIL VERSION
Output:
3.3.9
STAF local EMAIL HELP
Output:
EMAIL Service Help SEND < TO <Address> | CC <Address> | BCC <Address> >... [FROM <user@company.com>] [CONTENTTYPE <contenttype>] < MESSAGE <Message> | FILE <File> [MACHINE Machine] > [SUBJECT <subject>] [NOHEADER] [TEXTATTACHMENT <file>]... [BINARYATTACHMENT <file>]... [ATTACHMENTMACHINE <machine>] [RESOLVEMESSAGE | NORESOLVEMESSAGE] LIST SETTINGS SET [MAILSERVER <mailserver>] [PORT <mailport>] [SOCKETTIMEOUT <Number>[s|m|h|d|w]] [BACKUPMAILSERVERS <Space-separated list of backup mailservers>] [CONTENTTYPE <contenttype>] [RESOLVEMESSAGE | NORESOLVEMESSAGE] VERSION HELP
The Email service maintains a machine log where it writes an entry when the following occurs:
The logname for the Email service is the name under which the service is registered.
Here is an example of what a Email service log on the local machine (where the registered name of the Email service is "Email") could look like (shown via a request from the command line in the table format):
C:\>STAF local LOG QUERY MACHINE {STAF/Config/MachineNickname} LOGNAME Email Response -------- Date-Time Level Message ----------------- ----- -------------------------------------------------------- 20071108-16:26:06 Info email service initialized, using mailserver na.relay.ib m.com port 25 backupmailservers [] 20071108-16:26:32 Info [tcp://staf2f.austin.ibm.com@6500:122] SEND TO [user1@ us.ibm.com] FROM user2 SUBJECT This is a test CONTENTTYP E text/plain TEXTATTACHMENTS [c:/temp/rc0.txt, c:/temp/ perf.txt] BINARYATTACHMENTS [c:/temp/stats1.gif] ATTACH MENTMACHINE staf3a.austin.ibm.com 20071108-16:26:32 Info [tcp://staf2f.austin.ibm.com@6500:122] 220 d03xxxx.boul der.ibm.com ESMTP Sendmail 8.12.11.20060308/8.12.11; Th u, 8 Nov 2007 15:26:24 -0700 20071108-16:26:33 Info [tcp://staf2f.austin.ibm.com@6500:122] 250 d03av04.boul der.ibm.com Hello user1.austin.ibm.com [9.99.99.153], p leased to meet you 20071108-16:26:33 Error [tcp://staf2f.austin.ibm.com@6500:122] 553 5.5.4 user2. .. Domain name required for sender address user 20071108-16:26:58 Info [tcp://staf2f.austin.ibm.com@6500:135] SEND TO [bdavid@ us.ibm.com] FROM user2@ibm.com SUBJECT This is a test CO NTENTTYPE text/plain TEXTATTACHMENTS [c:/temp/rc0.txt, c:/temp/perf.txt] BINARYATTACHMENTS [c:/temp/stats1.gif ] ATTACHMENTMACHINE staf3a.austin.ibm.com 20071108-16:26:58 Info [tcp://staf2f.austin.ibm.com@6500:135] 220 d03xxxx.boul der.ibm.com ESMTP Sendmail 8.12.11.20060308/8.12.11; Th u, 8 Nov 2007 15:26:50 -0700 20071108-16:26:59 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 d03xxxx.boul der.ibm.com Hello user1.austin.ibm.com [9.99.99.153], p leased to meet you 20071108-16:26:59 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 2.1.0 user2@ ibm.com... Sender ok 20071108-16:26:59 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 2.1.5 user1@ us.ibm.com... Recipient ok 20071108-16:27:02 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 Mail queued for delivery.
If you are having problems getting your mail server to send emails via the STAF Email service, you can try submitting the same email request via telnet. It should fail in the same way the STAF Email service fails. If so then you will need to investigate why your mail server is unable to send the email. Here are the steps to send the email via telnet (these commands are essentially what the STAF Email service is sending):
telnet <mailserver.company.com> 25That should initiate a telnet session to your email server (use the same email server and port that you are using with the STAF Email service).
HELO hostname.company.com MAIL FROM: STAFEmailService@hostname.company.com RCPT TO: userid@company.com DATA To: userid@company.com Subject: My subject From: STAFEmailService@hostname.company.com This is my email message . QUIT("hostname.company.com" should be the hostname of the machine where you are running the telnet session, and "userid@company.com" should be the email address to send the email to)
220 mailserver.company.com ESMTP Sendmail 8.12.11.20060308/8.12.11; Wed, 24 Sep 2008 19:36:00 -0600 HELO hostname.company.com 250 mailserver.company.com Hello hostname.company.com [9.xx.xx.xxx], plea sed to meet you MAIL FROM: STAFEmailService@hostname.company.com 250 2.1.0 STAFEmailService@hostname.company.com... Sender ok RCPT TO: userid@company.com 250 2.1.5 userid@company.com... Recipient ok DATA 354 Please start mail input. To: userid@company.com Subject: My subject From: STAFEmailService@hostname.company.com This is my email message . 250 Mail queued for delivery. QUIT 221 Closing connection. Good bye.
In addition to the common STAF return codes, the following Email
return codes are defined:
Table 1. Email Service Return Codes
Error Code | Meaning | Comment |
---|---|---|
4001 | IO Exception | An IO Exception occurred while sending the email. |
44XX 45XX |
SMTP Errors | The Email request generated an SMTP error. The SMTP error code is the last 3 digits of the error code. See section 4.2 in RFC 821 for an explanation of SMTP return codes (e.g. 450, 503, 553, etc). |
This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
/* * The Apache Software License, Version 1.1 * * * Copyright (c) 1999-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 1999, International * Business Machines, Inc., http://www.ibm.com. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */