Last updated: September 19, 2008
Installation and Configuration
SERVICE <EmailName> LIBRARY JSTAF EXECUTE <Service Jar File Name> \ PARMS "MAILSERVER <mailserver> [PORT <mailport>] \ [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" SERVICE email LIBRARY JSTAF EXECUTE c:/staf/services/email/STAFEmail.jar \ PARMS "MAILSERVER na.relay.ibm.com BACKUPMAILSERVERS \"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 PORT 25 CONTENTTYPE text/html" SERVICE email LIBRARY JSTAF EXECUTE c:/staf/services/email/STAFEmail.jar \ PARMS "MAILSERVER na.relay.ibm.com NORESOLVEMESSAGE"
SEND TO <Address>... [FROM <user@company.com>] [CONTENTTYPE <contenttype>] < MESSAGE <Message> | FILE <File> [MACHINE Machine] > [SUBJECT <subject>] [NOHEADER] [TEXTATTACHMENT <file>]... [BINARYATTACHMENT <file>]... [ATTACHMENTMACHINE <machine>] [RESOLVEMESSAGE | NORESOLVEMESSAGE]
TO specifies an email address to which the email will be sent. You may specify multiple TO options. This option will resolve variables.
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.
STAF local EMAIL SEND TO user1@us.ibm.com message "Test XYZ completed successfully." SUBJECT "Test XYX: Success"
STAF local EMAIL SEND TO user1@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 TO user3@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> | |
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 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>] [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 VERSION
Output:
3.3.2
STAF local EMAIL HELP
Output:
EMAIL Service Help SEND TO <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>] [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 with machine nickname client1 could look like (shown via a request from the command line in the table format):
C:\>STAF local LOG QUERY MACHINE client1 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 [bdavid@ us.ibm.com] FROM user 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 d03av04.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 dave2268.austin.ibm.com [9.53.53.153] , pleased to meet you 20071108-16:26:33 Error [tcp://staf2f.austin.ibm.com@6500:122] 553 5.5.4 user.. . 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 user@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 d03av04.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 d03av04.boul der.ibm.com Hello dave2268.austin.ibm.com [9.53.53.153] , pleased to meet you 20071108-16:26:59 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 2.1.0 user@i bm.com... Sender ok 20071108-16:26:59 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 2.1.5 bdavid @us.ibm.com... Recipient ok 20071108-16:27:02 Info [tcp://staf2f.austin.ibm.com@6500:135] 250 Mail queued for delivery.
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/>. */