Tuesday, June 2, 2009

(FAQ) How to send email from iSeries

I. Simple message

You will need to know the internet address(es) of the recipient(s). Use the SNDDST command to send the message.

1. TYPE: Use *LMSG (Long Message, 5000 characters maximum)
2. TOINTNET: The internet address of the recipient. Use the “+” for additional addresses.

Recipient Type is
*PRI for the TO addressee
*CC for CC: addressees
*BCC for BCC: addressees.

3. DSTD: This field contains the subject line of your message
4. LONGMSG: The text of your message.


SNDDST TYPE(*LMSG) TOINTNET((someone@SomeDomain.com) (someoneelse@hotmail.com *PRI))
DSTD(Here is your file!!) LONGMSG(Your test worked great!. Please call me if you have questions/comments. )

II. Send a file as an attachment

The file must exist in the QDLS directory structure. You need to know the name of the file.
You will need to know the internet address(es) of the recipient(s). Use the SNDDST command to send the message.

1. TYPE: Use *DOC (The document specified on the Document prompt (DOC parameter)
or the Document identifier prompt (DOCID parameter) is sent. The user must
have authority for the document before it can be sent).
2. TOINTNET: The internet address of the recipient. Use the “+” for additional addresses.

Recipient Type is
*PRI for the TO addressee
*CC for CC: addressees
*BCC for BCC: addressees.

3. DSTD: This field contains the subject line of your message
4. MSG: The text of your message (256 characters maximum).
6. DOC: The name of the document in 8.3 format, e.g., TESTMAIL.TXT, or whatever name exists in the QDLS folder.
7. FLR: The name of the folder in the QDLS directory, e.g., PCUPLOAD


SNDDST TYPE(*DOC) TOINTNET((someone@SomeDomain.com *PRI) (someoneelse@hotmail.com *PRI))
DSTD(Here is your file!!) MSG(File TESTMAIL.txt attached) SNDFMT(*NOCHG)

First of all, you have to understand that the AS/400 supported E-mail long before the Internet came around, and SMTP became popular. It used an e-mail system called SNADS that IBM developed specifically for their business machines.

That's why commands like SNDDST seem so complicated. They weren't designed for today's Internet e-mail, they were designed for SNADS and later adapted for SMTP.

Before explaining how to set up e-mail, I'm making the following assumptions:

* Your system is already configured for TCP/IP.
* You already have DNS lookups working from your iSeries to Internet domains as well as local domains.
* You have an Internet Service Provider (ISP) who has given you an outgoing mail server to relay your e-mail. Or you have an internal SMTP server that your company uses for e-mail.

The first thing you'll want to do is configure your iSeries SMTP server. This is used when sending mail as well as receiving it. Type the following command:



* AUTOSTART(*YES) tells the system you want this server to start automatically when TCP/IP is started.
* the MAILROUTER keyword tells where the iSeries should send outgoing e-mail to. This'll be the internal SMTP server that your company uses for mail, or the one that your ISP provided you.
* The FIREWALL(*YES) keyword tells the iSeries to always send mail though the MAILROUTER, never try to deliver it directly.
* ALWRLY(*BOTH) is used to configure who is allowed to send mail though this server. Do not set this to *ALL or spammers will be able to use your machine to send spam without your consent. With *BOTH, you'll have to use the ADDSMTPLE command to control which computers can use your SMTP server (more later).

You'll also want to make sure that e-mail messages are not split up, even if they're big. This has always seemed strange to me, but it's controlled by the CHGPOPA (Change POP3 Attributes) command.



As I mentioned above, you'll need to configure which IP addresses are allowed to send mail through your iSeries system. In my shop, all the computers who can send mail have IP addresses that begin with 192.168.5, so I run the following command:



You can run this command more than once if you need to add more than one subnet.

The next thing you'll need to do is set up a gateway that allows SNADS tools like SNDDST to send Internet e-mail. To do that, type the following commands:


USRD(‘Internet SMTP gateway’) SYSNAME(INTERNET) +


After running this command, the SNDDST command will use the gateway so that e-mail will be sent to the local SMTP server.

Now that SMTP is configured on your system, so go ahead and start the SMTP server



(If it was already running, use ENDTCPSVR to end it. Then use WRKACTJOB SBS(QSYSWRK) to make sure that all of the QTSMTPxxxx jobs end, then use STRTCPSVR to start it up again.)

Each user who needs to send e-mail using SNDDST will need to have a directory entry and SMTP e-mail address configured on the iSeries.





1. Use option 1=Add
2. Type the same name/address that you used on the ADDDIRE command
3. Enter the SMTP e-mail address for this user.

Once all of that is done, it should be easy to send off a test e-mail with SNDDST. For example:


TOINTNET(('unclebob@example.com')) +
DSTD('Put E-mail Subject Here') +
LONGMSG('Hi Bob. This is an E-mail message sent from my iSeries system.')

You should also be able to configure tools like Outlook, Firebird, Eudora, etc to send mail using your iSeries SMTP server. For user-written e-mail, that's nicer than using SNDDST. Though, SNDDST is still nice for automatic messages generated by programs.

There are also lots of free e-mail tools on the Web that can use this SMTP server. They provide many more capabilities than SNDDST does. But, alas, this message is getting too long, so I'll stop there.


  1. How do i send email from i-series using SNDDST where my document name is more than 12 characters

  2. In your example with the *DOC type, you have a DSTD set to use as a subject method. I'm researching this right now, because the document file name is all that gets put into subject line when the email is sent, not the text that I want to go in there, but the actual file name. I'm looking for a way around this. Every other part of the SNDDST command allows DSTD to work, but the *DOC, which is where I need it to work. Let me know your thoughts.

    Thanks, Dave Davis

    1. Did you ever figure out how to do this?

  3. When I send a text file that's stored in QDSL using SNDDST command, I am receiving gibberish in the body of the e-mail and not text file as a attachment. What am I doing wrong? Can anybody adise, please? I am sending exactly the way as described in example in here.

    ===> SNDDST TYPE(*DOC) TOINTNET(('pschuck@toronto.ca')) DSTD('Test SNDDST') MSG('Attachment') DOC(S01.TXT) FLR(TSTFLR)

  4. Send a Spool File from AS/400 with a Specific Subject Line and Message Body


    The explanation and source are available from the URL above. It's worked well for me.

  5. Hello,

    You can use the service(department) of Clever Technologies. You will find a multitude of solutions which allow to send and to receive information.