Skip to main content  
  Easy400   |       iSeries home


August 8, 2015 release

How would you like to receive e-mail messages into IFS directories of your iSeries (AS/400)?
There could be some good reasons for doing that:

  • you need to automatically process on your iSeries messages adressed to given users
  • you want to check some mail before re-distributing it to the appropriate people within your organization
  • you want to provide some controlled mail facility within your company

In order to achieve such objectives, you need a pop3 client running on your iSeries. Unluckily, however, no such utility or API is available within the basic iSeries software (apart from some JavaMail code that would challenge your patience).

If you happen to be an RPG programmer, you would therefore be happy to read about this public-source ILE-RPG POP3 client program authored by Koen Decorte from Belgium,, that you may easily download, install and customize to your needs.

This utility is very basic. For instance it would not be able to separate the components of the mail message (body and attachments) into different decoded parts.
Should you really need a more complete solution for receiving mail on your iSeries, please look at the AMailer component of the MMAIL delivery.
AMailer is a webmailer. However, you not need to use it as such, you may just take advantage of its way for receiving incoming mail while separating message bodies from attachments and decoding each single piece.
Check out topic Processing incoming mail your own way.

1. Highlights
2. Prerequisites
3. Installation
4. Manually testing the pop servers
5. Setting up the pop client
6. Other POP3READ database files
7. Running the POP3 Client program

1. Highlights
  • Define your users (mail receivers) on a simple database file
  • Run the pop3 client program: for each user the program will
    • contact the appropriate pop server
    • receive the mail messages into IFS stream files
    • update the index of mail received
    • remove mail messages from the hosting pop client, if requested so
  • Optionally have your own programs to go through the mail index, display or process the received mail messages.

2. Prerequisites
As just sources are delivered, you need the ILE-RPG Compiler (57xxWDS Option 31, library QRPGLE) to compile the pop3 client program POP3READ/POP3READ. You may then save library POP3READ, restore it on other iSeries boxes and run the pop3 client program without the ILE-RPG Compiler prerequisite.

3. Installation
  1. Download the file
  2. Unzip the file. Two files are generated: pop3read.savf and readme.txt.
  3. On the AS/400
    crtsavf qgpl/pop3read
  4. Use FTP to send file pop3read.savf to library QGPL (detail instructions in file readme.txt).
  5. Signon as a USRCLS(*SECOFR) user profile
  7. If you already have library POP3READ, rename it POP3READO
    This procedure:
    • creates objectes in library POP3READ (service program, modules, programs, commands, etc.)
    • if not yet existing, it creates library POP3READTA containing your local files
    • if not yet existing, it creates IFS directory /pop3 .
Note - To install POP3READ on a production system without ILE-RPG compiler:
  • Save library POP3READ from the system you have installed it
  • Restore it on the production system
  • Either save/restore also library POP3READTA, or run command POP3READ/INSTALL on the production system to create and populate library POP3READTA.

4. Manually testing the pop servers
Before setting up the pop client, you want to make sure that your iSeries is able to contact the pop servers serving your users.

First of all, you need to take a note of their IP addresses. For instance, if your pop server has the DNS name, on the iSeries command entry screen type command
   ping ''
to display its IP address (e.g. Take a note of this IP address.

Next, you have to check whether your iSeries is able to contact this pop server on port 110. In fact, if your AS/400 is in the public network (Internet) but is protected through a firewall, most likely it cannot connect to port 110 of the pop server, until the firewall protection is changed. To perform this test, from an iSeries command entry screen enter command
   TELNET RMTSYS('pop_server_ipAddress') PORT(110)

If no response, then you have a connection problem.
Otherwise, you may have the following dialog:

+OK POP3 server ready
USER KIBEL           
-ERR unknown command   (first user command on telnet always gives -err on iseries)
USER KIBEL            
+OK POP3 server ready
PASS ********** (password replaced)                       
+OK start sending message         
+OK 11 messages (176957 octets)   
1 8674                            
2 14571                           
3 9380                            
4 33052                           
5 4387                            
6 4584                            
7 37047                           
8 5984                            
9 33974                           
10 7753                           
11 17551                          
UIDL 1                
+OK 1 JW443098.NOTNS  (file which resides in /qtcptmm/mail/..... if the pop server is an iSeries)
..... MAILLISTING (if command TOP is used than only mailheader until first blank line is send.)
QUIT (exit)

  • Note 1 - At the beginning of the dialog (see above), the POP3 must answer
    • + OK POP3 server ready
      (traditional basic POP3 server)
    • + OK The Microsoft Exchange POP3 service is ready
      (Microsoft Exchange POP3 server)
    If you receive a different answer, then this POP3 server is not supported by POP3READ.
  • Note 2 - When the communication to the POP3 server is through Secured Socket Layer (SSL),
    • you must use DCM (Digital Certificate Manager) and create a Certificate Store needed by SSL, see this page.
    • SSL POP3 servers usually communicate through port 995 instead of port 110.
  • Note 3 - If you experiment problems in connecting to the desired POP3 server, you may try a bypass solution.
    See A way to bypass remote POP3 connection problems.

5. Setting up the pop client
Before starting the pop client, you must define the users you want to serve. Basically, for each user you must:
  • add a record to file POP3READTA/POP3ACC (accounts)
  • add a subdirectory to IFS directory /pop3 (created by the INSTALL program),
    named as the POP3ACC account code, example
    MD DIR('/pop3/BSmith')
This is how you do it:
  1. Add a record to file POP3READTA/POP3ACC (accounts)
    STRDFU option 5 on file POP3READTA/POP3ACC:
     WORK WITH DATA IN A FILE                       Mode . . . . :   ENTRY
     Format . . . . :   ACCREC                      File . . . . :   POP3ACC
     Account code:        __________ (example BSmith)
     Description:         __________________________________________________
     User:                ________________________________________________________
     Password:            ________________________________________________________
     Server IP address:   _______________
     Retain after rtv:    _
     Remove after delete: _
     Log communications:  _
    Account code: this is an alphanumeric identifier to become a unique record key. It is also the name of the subdirectory to be created in the IFS directory '/pop3'.
    Description: any useful description to identify this user, e.g. full name
    User name: the user name as it is known to the pop server.
    For an Outlook user, this name can be found in Tools -> Account... -> Properties -> Server -> Account name.
    For an iSeries user, this would be an user profile name.
    Password: the user password known to the pop server.
    For an Outlook user, this is the same password specified in Tools -> Account... -> Properties -> Server -> Password.
    For an iSeries user, this would be the password of the user profile.
    Without correct username and password, mail messages cannot be received.
    Server IP address: the IP address of the pop server.
    For an Outlook user, the pop server name is specified in Tools -> Account... -> Properties -> Server -> Incoming mail (POP3). You have then to ping it to find the IP address.
    Retain after retrieve: specify 'Y' if a message should NOT be removed from the pop server after it has been retrieved by the pop client. If you specify any other character, a message will be removed after having been retrieved.
    Remove after delete: A messages received can later be optionally marked for deletion by inserting a 'D' in field DLFLAG of file POP3READTA/POP3MAIL (the index of the mail received). If this is done, and the field Retain after retrieve contains 'Y', then this message is removed from the pop server at the next connection.
    Log communications: specify 'Y' if you want all socket communications be logged for this user. The log is kept in file POP3READTA/POP3LOG. This should be done just temporarily for debug purposes.
  2. Add a subdirectory to IFS directory /pop3
    Once you have added a record to file POP3READTA/POP3ACC, you should create a subdirectory -named as the account code- in the IFS directory '/pop3'. The pop client will store messages retrieved for this user in such a subdirectory.
    Messages are stored as stream files with name Mnnnnnnnnnn.MHTML.
    Files with extension MHTML (MIME HTML) can be efficiently displayed by MS Interner Explorer.

6. Other POP3READTA database files
A few other database files are used by pop3 client program POP3READ/POP3READ.
The may be proficiently be used in local applications.
POP3UID Each mail message received is assigned a unique numeric identifier, which is used to build the name of the IFS stream file. This file contains a list of the identifiers already assigned.
POP3MAIL This is the index of the received mail messages, ordered by account code and message identifier as known by the pop server. Other pieces of information are the stream file id, sender's name and address, subject, number of lines and two flags. One flag tells whether the message was already removed from the pop server, another flag is used to book the message for removal from the pop server at the next pop3 client run.
POP3TO For each mail message, this file lists all the e-mail addresses supposed to receive it (To, Cc, Bcc). It can be used to re-address received messages.
POP3LOG This is a log of all the socket transactions exchanged with the pop servers for those users that have requested such a trace to be active. See database file POP3READTA/POP3ACC. Using this log may impact performance.
See also the comments in POP3READ/QCLSRC member COMPILE.

7. Running the POP3 Client program

Once the database setup has been performed, to run the POP3 Client program:
  • if only non-SSL POP3 servers,
  • if only SSL POP3 servers,
  • if non-SSL and SSL POP3 servers, run command CALL POP3READ/POP3ALL or POP3READ/POP3ALL
  • to display the index of the mail received:
  • to view the messages received for a given account code:
       WRKLNK '/pop3/account_code/*'