z/OS email FAQs

SMTP-Sendis the easiest way to send email from z/OS. The following FAQs provide some insights into sending email from z/OS in general.

What are my options for sending email from MVS? You can send email from z/OS, including CICS by coding the datastreams yourself or by using a third-party product to do it for you. IBM provides a simple REXX exec called SMTPNOTE to send simple text messages. XMITIP is a REXX freeware exec that sends emails from Batch or TSO/ISPF. SMTP-Send sends emails from Batch, TSO/ISPF and CICS.Click to see a comparison of SMTP-Send and XMITIP

What is SMTP? What is its purpose? SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending and receiving mail. It is Internet's standard host to host mail transport protocol. It is defined by RFC821. RFC (Request For Comments) documents define standards for protocols and policies of the Internet.

What is RFC822? RFC822 is the standard for Internet Text messages. This standard specifies the syntax for text messages that are sent among computer users within the framework of "electonic mail". RFC822 has been updated by various RFCs such as RFC1123, RFC1138, RFC1148, RFC1327, RFC2156

What is MIME and why is it important? MIME is short for Multipurpose Internet Mail Extensions. MIME is defined and extended by many different RFCs. MIME allows the sending of binary and other complex messages such as HTML through the text based protocols of SMTP. Without MIME, the sending of attachments or in-line HTML would be impossible.

What does a SMTP data stream consist of? The SMTP data stream consists of a series of statements (defined by RFC821) identifying the start of the SMTP conversation, the sender and recipients, followed by the message data. The message data usually includes a series of RFC822 message headers that describe the message to the receiving email client. The actual message text follows the message headers.
Here is a simple annotated example.
    The HELO command begins the SMTP conversation. It identifies the sending SMTP server or agent to the receiving SMTP server. In the above, BAR.COM is the domain name of the sending SMTP server.

    MAIL FROM:<foo@bar.com>
    MAIL command tells the receiving SMTP server that a new mail transaction is starting. It states the senders mailbox, which can be used to report back any errors.

    RCPT TO:<wayne@bar.com>
    RCPT identifies a single recipient, specifying the destination mailbox. If accepted, the receiving SMTP server returns a 250 OK reply and stores the destination mailbox, in this case <jones@bar.com>. This command is repeated for each recipient.

    DATA command is the 3rd step in the SMTP procedure. If accepted, the receiving SMTP server returns a 354 intermediate reply and considers all succeeding lines to be message text. The mail data includes the memo header items such at DATE, Subject, TO, CC and From. The format of the memo headers is specified by RFC822. The following is all considered mail data;
      Date: Fri, Jul 16 2019, 13:41:30 -0400
       From: "Commissioner Gordon" <foo@bar.com> 
       To: "Bruce Wayne" <wayne@bar.com> 
          Please fix the bulb in the searchlight    
    The actual message data follows the RFC822 message headers, in this case the last line, in bold text.
    A single period marks the end of the current message text. The receiving SMTP server will expect either another HELO command to begin a new conversation or a QUIT command to end the current conversation.

    Ends the conversation and specifies the receiving server can now close the transmission channel.

How can I send attachments? SMTP-Send can send attachments as can XMITIP.
SMTPNOTE cannot send attachments. Sending of attachments requires the data to be encoded so that the binary data can be transmitted across the network using the text-only SMTP protocols. The data itself must be encoded and MIME used to describe the attachment so that it can be recognised at the receiving end.
To do it yourself, you need to encode the attachment (base 64 encoding is the most popular choice) and provide the necessary MIME headers to describe the attachment

How can I prevent users from pretending to be someone else when they send mail? SMTPNOTE creates the from email address using the TSO user's Userid. If a complete SMTP datastream was created by a batch job and sent to IBM's SMTP server, that piece of mail can claim to be from whoever it wants to.
Some companies have used JES2 exit 31 (SSI allocation) to restrict who can use the Writer name of SMTP, based upon the program name and SAF (RACF) userid.
SMTP-Send provides a verification exit that allows companies to verify or replace the sender's address based upon the SAF id, and Jobname and other criteria.

How does SMTP-Send insulate me from the various Internet Protocols? SMTP-Send uses RFC821 and RFC822 protocols to send mail but uses an easily understood and programmed control statement interface for specifying the information required by the RFC821 and RFC822 protocols. When binary data is being transmitted, SMTP-Send automatically uses the appropriate MIME protocols to preserve the data fidelity and ensure that the data arrives at the receiving end correctly.

Where can I get more information about the IBM SMTP Server? The SMTP Server is packaged as part of the z/OS Communications Server. An excellent redbook on the MVS TCP/IP tasks is IBM z/OS V2R1 Communications Server TCP/IP Implementation Volume 2: Standard Applications
Seehttp://www.ibm.com/software/products/en/commserver-zos for information about Communications Server maintenance.

Do I have to use the IBM SMTP Server? The SMTP Server is supplied as part of the z/OS Communications Server. It performs a number of functions such as receiving incoming SMTP traffic and reading outgoing SMTP traffic from the JES Spool and sending it to its ultimate destination. If you don't want to accept inbound SMTP traffic, see "How do I prevent spammers from hijacking my SMTP Server" below.
For outgoing traffic, most organizations employ a relay server, sometimes called a smart host, to act a central point for outgoing mail. SMTP-Send's Spool Server reads outgoing SMTP items from the JES Spool. The SMTP-Send Spool Server delivers a single datastream for all recipients of an email, to the relay server. IBMs SMTP Server will do this for each recipient. Unlike the IBM SMTP Server, it does not attempt to deliver each piece of mail to it recipients. Instead it sends the entire SMTP datastream to a remote SMTP mail server (known as a relay server).

My SMTP server doesn't recognize the @ character in my email addresses. How can I send mail? The @ character is defined as EBCDIC x'7C' in most but not all z/OS codepages. The SMTP Server uses the @ symbol to separate the local part from the domain in email addresses and expects the @ symbol to be x'7C'.
A recent fix to CommServer, PQ36249, addresses this issue allowing a different character to be used as the @ symbol.

How can I get my SMTP Server to relay all mail to another SMTP mail server? You can simply use SMTP-Send's Spool Server to handle this, or perform steps 1 through 4, below.
IBM's SMTP server can be instructed to relay all outgoing mail for which it cannot locate the host to another SMTP server. If the SMTP server is configured to not resolve any addresses, then all recipients will be unknown and you can direct the mail to another server.
  1. Copy your TCP/IP profile data set (DDname SYSTCPD in the SMTP started task) to a new data set.
  2. In your SMTP CONFIG data (DDname CONFIG in the SMTP started task) specify a IPMAILERADDRESS statement. The syntax is IPMAILERADDRESS xx.xx.xx.xx which is the numeric IP address of the target SMTP mail server.
  3. Comment out the NSINTERADDR statements in the copied SYSTCPD data set. This will prevent the SMTP server from using Domain Name Services to resolve the location of any email address. SMTP will now only use the site table to resolve email addresses into target host IP addresses.
  4. Change your SMTP started task JCL to use the altered copy of the TCP/IP parameters and the updated CONFIG data set .Restart your SMTP server. Any mail for which the IP address of the target host cannot be determined will now be redirected to the SMTP server named in the IPMAILERADDRESS statement.

How do I prevent spammers from hijacking my IBM SMTP Server?
  • Don't connect directly to the Internet. A firewall can be used to block any unwanted traffic. If you don't use your SMTP server to receive external email, ask your firewall people to disable port 25 to inbound traffic. That way spammers can't send any inbound relay traffic.
  • Relay all of your email to another non-MVS SMTP server that can detect the unwanted relay traffic.
  • If you send all of your email throught the Spool/NJE interface you can set MAXMAILBYTES to 1 which means you only accept 1 byte messages over TCP connections
  • You can code the SMTPEXIT to inspect all traffic coming into your SMTP Server via TCP/IP. With the addition of APAR PQ13476, you can also inspect data entering via the JES Spool. Refer to Communications Server IP Configuration Reference for additional information on SMTP Exits.
  • Use SMTP-Send's Spool Server instead of IBM's SMTP Server to only accept SMTP traffic from the spool.

How can I tell who's sending emails? Using IBM's SMTP Server to accept the mail, you can turn on Logging and view the LOGFILE to see the headers from the email traffic.
Using SMTP-Send you can write records to SMF, CICS journals or a sequential dataset which contain details about each email such as which user sent it, to which users, with how many attachments, what was the subject, what is the size and more.