How to Send Email from an AS/400 - V4R2 or higher version

时间:2015-11-19 ┊ 阅读:3,296 次 ┊ 标签: 经验 , 系统 , 配置

How to Send Email from an AS/400 rev C 1/5/11
This procedure is intended for emailing PDF files created by FORMagic/400 PDF. However, it can also be used for
sending email from other applications. It is based solely on the use of AS/400 commands and facilities; no additional
software is required. It supports emails with optional attached files, such as purchase orders and invoices. It is based on
the AS/400 command SNDDST which has somewhat limited functionality. Yet, it is still sufficient for most needs.
This procedure, and the necessary AS/400 setup instructions below, do not provide support for receiving email on an
AS/400 as doing so is beyond the scope of our product and its support.
The necessary configuration can be done in numerous ways. We can only support methods similar to the one
documented below. These instructions are intended to represent a general approach only; the user is responsible for
evaluating the specific needs of his environment.
Note that changing existing parameter values to conform to the values we have noted below could impact other functions
on your system.
The user is responsible for all security configuration on his AS/400, but we believe these instructions are sufficient for
the majority of users wishing to configure send email only.
 OS/400 V4R2 or higher.
 An SMTP email sending server must exist somewhere on your network. This can include an ISP service.

  1. Setup instructions - TCP/IP access to email send server:
    a. You must know the TCP/IP address of your email sending server. This is often referred to as an email gateway.
    It could be on your own AS/400, on a network server, or part of an ISP service. In each case, it must be
    properly configured as an SMTP send server. If you have a POP3 client capable of sending email, then you
    would most likely use its configured outgoing email TCP/IP address for this purpose. This address will be
    referred to as YOUR-SMTP-ESA (SMTP email server address) below.
    b. Check the TCP/IP Hosts Table to see if an entry exists for YOUR-SMTP-ESA. Use command CFGTCP, option
  2. If not, add an entry similar to this:
    INTNETADR(your-smtp-esa) HOSTNAME('SMTP')
    You can also use ADDTCPHTE to add this entry.
    If YOUR-SMTP-ESA is already in this table, make a note of its HOSTNAME entry and use it wherever 'SMTP'
    is referred to below.
    c. If a router sits between your AS/400 and your email send server, an entry like this will be required. Use
    command CFGTCP, option 2 to check it. If not, add an entry similar to this:
    You can also use ADDTCPRTE to add this entry or CHGTCPRTE to change it.
    Caution: This step may require changes based on your actual network.
    d. Ping the email sender with each of these commands. Both must work!
    PING *INTNETADR INTNETADR('your-smtp-esa')
    e. The TCP/IP Host Table must contain an entry for your own system. Use command CFGTCP, option 10 to see
    if the entry below exists. If not, add an entry similar to this one.
    INTNETADR(your-system-tcpip-addr) +
    HOSTNAME((your-system-name) (
    Use DSPNETA to verify or obtain Your-System-Name. Use CHGTCPDMN to obtain (don't
    change it!).
    This setup provides one entry with two values for your system:
     the first value is simply your system name or the "short name"
     the second is the "long name" or sysname.domainname (ie,
    You can also use ADDTCPHTE or CHGTCPHTE to add or change this entry.
  3. Setup instructions - SMTP settings:
    a. The SMTP server must be started in order to send email. Change or verify these SMTP attributes or make other
    settings appropriate for your environment. Use CFGTCPSMTP option 3, or:
    When making the above entry, also verify these parameters:
    We are uncertain as to whether other values will co-exist with the setups we are describing. However, be
    cautious if making any changes since they could impact existing applications on your system.
    b. These instructions assume you are sending email only and any reply must be sent to an address on another
    system. In order to insure the FROM address used in your emails is valid, an alias entry must be set up for
    every User ID that will send email. Note that if you will be sending email only from applications all running
    under the same User ID, only one entry will be needed. You may also be able to use the USERID parameter of
    the SNDDST command to limit the number of entries that are required.
    Configuration is a two step process. First, each user to be sending email must be listed in the System Directory.
    Use WRKDIRE ALL to view and add entries. Certain parameter values are required or highly recommended;
    any value can probably be used for others.
    ADDDIRE USRID(userid address-is-systemname) USRD('Person's name, etc') +
    USER(local-userid) SYSNAME(
    Note that some of these parameters will actually be stored as expanded values. PREFADR will be displayed as
    Note: If your user profile belongs to a group, you may have to add the Group Profile as a user as well.
    Next, use CFGTCPSMTP option 1 to add an entry for each of the email users to the SMTP System Alias Table.
    Four values are required for each entry:
    User ID and Address - must match the WRKDIRE User ID and address
    SMTP ID and domain - this is your address where you receive email. It is your FROM address and
    actually has nothing to do with the send process except to establish the FROM address. For instance, would use:
    SMTP ID: john
    SMTP Domain:
    c. One generic entry is required in the System Directory to route email from the AS/400 to all Internet users. Use
    WRKDIRE ALL to see if this entry exists; otherwise add it:
    ADDDIRE USRID(INTERNET SMTPRTE) USRD('Internet generic email user') +
    USRIDX) +
    Note: The entry of the PREFADR parameter information is different for the ADDDIRE command versus
    WRKDIRE option 1! When using WRKDIRE, make entries as follows:
    Preferred address: 9
    Address Type: ATCONTXT
    Field Name: NETUSRID IBM
    Also, verify this entry exists (it probably does) or add it:
    These instructions assume the system name TCPIP is used. It must match the value used in setup steps below,
    and some system objects are often pre-configured with this value. The parameter values for NETUSRID,
    MSFSRVLVL, and PREFADR are vital.
    d. Verify a distribution queue exists or add it. Use CFGTCPSMTP option 12 for SNADS configuration, then
    select option 1 for Distribution Queues. An entry should exist or be created with the values below. You can
    also use ADDDSTQ. Other parameters should generally be defaulted.
    e. Verify a routing table entry exists or add it. Use CFGTCPSMTP option 12 for SNADS configuration, then
    select option 2 for Routing Table.
    System Name/Group: TCPIP
    Description: TCP/IP Routing
    Service level: Use these values for all service levels
    Queue name: QSMTPQ
    Maximum hops: DFT
    f. Mail services must know how to route mail to the Internet. Use the command below to verify existing values.
    The SMTPRTE value is critical, but we have not assessed the effect of changing the other parameters.
    g. Authority issues can arise and cause the Mail Server Framework (MSF) facility to terminate. To eliminate that
    possibility, view these object authorities with EDTOBJAUT. For each object, verify the authority is at least
    USE for users QTCP and QMSF. Add or enhance the authority as needed. CHANGE is okay in lieu of
    USE. (continued on next page)
    Step 2a above sets up SMTP to Autostart. If it is not running now, you can also start it with:
    h. The MSF must search the System Directory to find information for routing email to the Internet. Searching
    must be properly enabled or the MSF will terminate with error code 05.
    First, verify searching is enabled. Use CHGSYSDIRA to verify Allow Search is set to *YES. If *YES, assume
    everything is okay and go to the next major step (i) below.
    If Allow Search is set to *NO or if MSF terminates with error code 05 even though *YES is configured,
    continue with these steps:
  4. If MSF is terminating with error code 05 even though it is set to *YES, change it to *NO, then
    continue with these steps to set it back to *YES.
  5. Locks may be present on one or more of these *FILE objects in the QUSRSYS library. These locks
    must be released before the Allow Search parameter can be set to *YES.
    Use WRKOBJLCK to determine which objects, if any, are locked. If no locks are held on these
    objects, skip to step 5.
  6. Some locks may be held and retained by various CFGxxx commands used during the configuration
    steps described herein. To clear these, sign off and sign on. Do not use any of the CFGxxx commands
    until this section is completed as doing so may re-establish the locks.
  7. Some locks may be held by SNADS or other subsystems. These subsystems must now be ended. On
    our systems, this is subsystem QSERVER.
  8. Use CHGSYSDIRA to set Allow Search to *YES.
  9. Restart any subsystems ended in step 4.
    i. Sending email requires that TCP/IP, SNADS, SMTP, and MSF jobs be active. Configuring these processes is
    beyond the scope of our support if it is much beyond what is described in this document. Configuration can be
    done numerous ways and many issues can arise. If your environment uses default settings, the configurations
    we have described should work.
    However, the necessary jobs must be active. We will assume TCP/IP and SNADS are, so that leaves SMTP
    and MSF to be dealt with.
    Step 2a above sets up SMTP to Autostart. If it is not running, you can also start it with: STRTCPSVR *SMTP
    MSF is started automatically by other processes, but if it terminates, it can be started with: STRMSF
    Note: You may find that you must end and restart some of these processes in order to allow them to use the
    new configurations. You can do this as follows:
    STRMSF *3
    *1 - SNADS functions must be running, but how to start/stop them will vary widely
    depending on how your system is configured.
    *2 - You may have to use *ALL in lieu of *SMTP, but this could impact other applications.
    *3 - If MSF aborts, you may have to ENDMSF and STRMSF with *CLEAR to clear previous
    distributions which have been queued but not sent.
    You can also use these commands to end and re-start these processes whenever needed.
  10. Setup instructions - Time for the Acid Test:
    a. The SNDDST command is used to send the email. The TYPE parameter provides multiple basic methods for
    sending, but some do not support sending email to the Internet. When the subtleties of this command are
    studied carefully, it can do much more than is first apparent. Even with its limitations, it is normally adequate.
    For now, let's just do a quick test to see if the configuration we have established can actually send an email. If
    not, check the entire configuration you have established very carefully.
    TOINTNET(( SUBJECT('This is the subject') +
    MSG('This is the short message parameter') LONGMSG('This is the long message parameter')
    Note that LONGMSG is required, but MSG is optional. If both are used, the message text is constructed as
    MSG, several blank lines, then LONGMSG.
    Now, check email at the TOINTNET address and see if you have received the message. DSPDSTLOG may be
    of use if a problem occurs.
    b. Test an email with an attached document. The document must be in a QDLS folder. Note that LONGMSG and
    SUBJECT are not allowed, and only one document can be attached. The document name will be used as the
    subject. There does not appear to be any way to freely control the text used as the Subject.
    TOINTNET(( MSG('This is a test') DOC(document) FLR(folder)
    c. You can also send an email with an attached document where the source is a database file. However, this
    command does not work as generally expected; so we will leave it to you to do the necessary experimentation to
    see if it can be effective for your needs. Use SNDDST TYPE(*FILE).
    d. Multiple Internet recipients, CCs, and BCCs can be used in SNDDST. However, some versions of OS/400 have
    a bug involving the use of Internet Recipient Type *CC. This bug causes the attachment to be inserted as
    corrupted message text. Be careful when using *CC.
    e. If the above summaries of using SNDDST do not meet your needs, additional detailed information provided in
    Redbook SG24-4703 may be useful. Check the IBM Redbook site, or send us an email requesting
  11. Setup instructions - Other Situations:
    a. For V4R2 and prior, attachments may be split into multiple attachments and/or corrupted. If you create a data
    area QUSRSYS/QTMSNOSPLT, it will turn off message splitting. V4R4 and later uses the CHGPOPA
    command with MSGSPLIT(*NOMAX) parameter to turn off message splitting. Once you have made this
    change, stop and restart your SMTP server.
    b. Unsent mail may be stored in folder /qtcptmm/attabox. Use WRKLNK to view. This may be helpful for
    debugging when mail is not being sent.



  1. 找这篇文章好久了,google回来就好了

    1. maybe helps.




终极解决sendmail & mutt 邮件乱码问题[sh]

终极解决sendmail & mutt 邮件乱码问题[sh]

自从上次把所有站点https后,一直没怎么看服务器。这两天突然发现所有从服务器自动发出来的邮件全部乱码,实在让我强迫症发作!今天终于得空赶紧研究一翻。 系统:Centos6.2 没有附件时乱码如下: -----邮件原件----- 发件人: Kevin [mailto:admin@amkevin...


今天经历了一翻折腾,把一个需要登录网站并js动态加载的数据一一给抓下来了。 首先,登录时有cookie,我们需要把cookie保存下来,用urllib2构建request时加入header信息,这时还多了一点,虚构了浏览器信息,让服务器以为是正常的浏览器发起的请求,这样可以绕过简单的反爬虫策略...
邮件发送失败小结Deferred: Connection timed out with[Port 25]

邮件发送失败小结Deferred: Connection timed out with[Port 25]

一直在忙,尽管没有忙出什么成果,也不知道忙了啥。 周末了,终于有时间看了一下自己的小服务器,发现邮件提醒好久没有发出来了. 赶紧看了一下maillog,发现: Jul 1 15:35:02 ebs-xxx sendmail[18015]: w5UK022f017326: to=<xxx...


首先说一下什么是journal,字面翻译过来就是日志,其实很简单,就是日志记录。在as/400上所有的对文件的操作都可以通过journal记录下来,以防任何不测用以数据回滚、调查等需要。 其实在实际项目中,真正遇到需要回滚数据的时候真的是非常之少,在400上工作这么多年,基本没发生过数据回滚的...
IBM DB2 SQL to_char 函数用法总结[SQL]

IBM DB2 SQL to_char 函数用法总结[SQL]

在用sql处理数据时经常会碰到日期时间格式转换的问题,其中to_char函数有时候就会用到,特别的方便。 作为ibm提供的内置函数,功能和varchar_format差不多。 首先看一下to_char语法: TO_CHAR(time_stamp, format_string) to_char...