Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sending Emails from Z/os with REXX

1,236 views
Skip to first unread message

Jay Pillai

unread,
Dec 28, 2005, 9:02:04 AM12/28/05
to
Is it possible to send Emails from a Z/OS system using REXX. Now we do it
with BPXBATCH, and for
some reason some mails get lost. I was wondering if there is a better way
of doing this.

Jay

This e-mail, including attachments, is intended for the person(s) or
company named and may contain confidential and/or legally privileged
information. Unauthorized disclosure, copying or use of this information
may be unlawful and is prohibited. If you are not the intended recipient,
please delete this message and notify the sender

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

John P Kalinich

unread,
Dec 28, 2005, 9:06:33 AM12/28/05
to
You can do something like this, but then SMTP has it's problems too.

Address TSO
XMIT jes2node.SMTP DDNAME(EMAIL)

Regards,
John Kalinich
Computer Sciences Corp


Jay Pillai
<Jay_Pillai To: TSO-...@VM.MARIST.EDU
@SWISSRE.COM> cc:
Sent by: TSO Subject: [TSO-REXX] sending Emails from Z/os with REXX
REXX Discussion
List <TSO-REXX


12/28/2005 08:01
AM
Please respond
to TSO REXX
Discussion List

Is it possible to send Emails from a Z/OS system using REXX. Now we do it
with BPXBATCH, and for
some reason some mails get lost. I was wondering if there is a better way
of doing this.

Jay

----------------------------------------------------------------------

kpin...@tiaa-cref.org

unread,
Dec 28, 2005, 9:39:35 AM12/28/05
to

Use REXX TCP/IP Sockets:

/* REXX */
smtp_server = ...
smtp_from = ...
smtp_address = ...
smtp_to = ...
smtp_replyto = ...
crlf = x2c('0d25')

/* SMTP Initialization */
str = Socket('initialize', Date(B))
Parse Var str sockrc subtaskid maxdesc tcpipuser
str = Socket('Socket', 'af_inet', 'stream', 'tcp')
Parse Var str sockrc sockid
str = Socket('SetSockOpt', sockid, 'sol_socket', 'SO_ASCII', 'on')
server_info = 'AF_INET 25 ' || smtp_server
str = Socket('Connect', sockid, server_info)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length smtp_response
msg= 'HELO ' || smtp_server || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)


/* Mail Message */
msg= 'MAIL FROM:<' || smtp_from || '>' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
msg= 'RCPT TO:<' || smtp_address || '>' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
msg= 'DATA' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
the_subject = 'This is a Test #1'
msg = 'To:' smtp_to || crlf ,
|| 'Reply-To:' smtp_replyto || crlf ,
|| 'Subject:' the_subject || crlf ,
|| 'X-Mailer: REXX Exec on ZOS' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Send', sockid, crlf)
msg = 'This is a test (#1) from ' || Userid() || crlf
str = Socket('Send', sockid, msg)
msg = crlf || '.' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
/* End of Mail Message */

/* SMTP Termination */
msg= 'QUIT' || crlf
str = Socket('Send', sockid, msg)
str = socket('Close', sockid)
str = socket('Terminate', subtaskid)
Say 'Email sent to ' smtp_to

Exit

John P Kalinich

unread,
Dec 28, 2005, 10:06:23 AM12/28/05
to
Yes, you have to do all of the formatting. I forgot about Lionel's XMITIP,
which is definitely the way to go.

Regards,
John Kalinich


Paul Gilmartin
<gilmap To: TSO-...@VM.MARIST.EDU
@UNIX.STORTEK.CO cc:
M> Subject: Re: [TSO-REXX] sending Emails from Z/os with REXX
Sent by: TSO
REXX Discussion
List <TSO-REXX


12/28/2005 08:19


AM
Please respond
to TSO REXX
Discussion List

In a recent note, John P Kalinich said:

> Date: Wed, 28 Dec 2005 08:06:19 -0600


>
> You can do something like this, but then SMTP has it's problems too.
>
> Address TSO
> XMIT jes2node.SMTP DDNAME(EMAIL)
>

Does this require considerable formatting of the file?

There's also XMITIP:

Linkname: New release XMITIP 5.34 available
URL:
http://bama.ua.edu/cgi-bin/wa?A2=ind0505&L=ibm-main&D=1&O=D&I=1&P=141872

Disclaimer: I haven't tried it; however it's often recommended on
IBM-MAIN.

-- gil
--
StorageTek
INFORMATION made POWERFUL

Paul Gilmartin

unread,
Dec 28, 2005, 10:25:27 AM12/28/05
to
In a recent note, "Scott, John (Endevor)" said:

> Date: Wed, 28 Dec 2005 15:16:35 -0000
>
> I tried XMIT and can see the xmit output sitting on SDSF on my userid with
> class D and DEST SMTP.
> Is something else required ?
>
Do you need to start a writer? Do you need to specify WRITER=?

Scott, John , Endevor

unread,
Dec 28, 2005, 10:45:49 AM12/28/05
to
We have a task called TCPIP running a program EZBTCPIP.
Do we need a SMTP task too ?
Is anything else required in JES etc ?

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU]
Sent: 28 December 2005 15:42
To: TSO-...@VM.MARIST.EDU
Subject: Re: sending Emails from Z/os with REXX

*** WARNING : This message originates from the Internet ***

The SMTP started task must be setup and running. That would be done by your
TCPIP administrator.

Regards,
John Kalinich
Computer Sciences Corp


"Scott, John
(Endevor)" To:
TSO-...@VM.MARIST.EDU
<John.P.Scott cc:
@RBS.CO.UK> Subject: Re: [TSO-REXX]


sending Emails from Z/os with REXX
Sent by: TSO
REXX Discussion
List <TSO-REXX


12/28/2005 09:16


AM
Please respond
to TSO REXX
Discussion List

I tried XMIT and can see the xmit output sitting on SDSF on my userid with


class D and DEST SMTP.
Is something else required ?


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU]
Sent: 28 December 2005 15:06
To: TSO-...@VM.MARIST.EDU
Subject: Re: sending Emails from Z/os with REXX

*** WARNING : This message originates from the Internet ***

Regards,
John Kalinich

There's also XMITIP:

-- gil


--
StorageTek
INFORMATION made POWERFUL

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX


The Royal Bank of Scotland plc, Registered in Scotland No. 90312.
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB

Authorised and regulated by the Financial Services Authority.

This e-mail message is confidential and for use by the addressee only. If
the message is received by anyone other than the addressee, please return
the message to the sender by replying to it and then delete the message from
your computer. Internet e-mails are not necessarily secure. The Royal Bank
of Scotland plc does not accept responsibility for changes made to this
message after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of
viruses, it is the responsibility of the recipient to ensure that the onward
transmission, opening or use of this message and any attachments will not
adversely affect its systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry out
such virus and other checks as it considers appropriate.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX


The Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB

Authorised and regulated by the Financial Services Authority.

This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate.

John P Kalinich

unread,
Dec 28, 2005, 11:25:16 AM12/28/05
to
Yes, you do need a SMTP task running. I think the only JES2 requirement is
to create a hostinfo file with the SMTPNJE interactive program. This is
all documented in the Communications Server bookshelf.

Regards,
John Kalinich
Computer Sciences Corp

----------------------------------------------------------------------

David Bjørnsten-Lindhard

unread,
Dec 28, 2005, 3:27:08 PM12/28/05
to
Hey Jay,

Theres also the solution to just use a rexx to make the socket connection
directly to a smtp server on your network.
In this way you can use a remote smtp server for the delivery. This rexx is
very "basic", you can use it to send short notes/messages etc.

Perfect for batch notify's and so on... It's easy to modify and to make into
what ever you want :)
Then you don't have to have smtp services installed on the zos or use any
other middle way delevery.

But again, this ain't bulletproof and and the "functions" are very simple.
Nothin mimes and so on. Just send a email :)

Use it from any other rexx like this...
call BEMAIL 'to@email', 'mail subject', 'mail body'

-----------------------------------
/* REXX */
PARSE ARG TOADDR, SUBJECT, BODY

SMTPSERVER = 'smtp.server.com'
SMTPHELO = 'myserver'
FROMNAME = 'Batch Notifyer'
FROMEMAIL = 'batch@myserver'

CALL INITIALIZE
R = SOCKET('CONNECT',SOCKET_ID,'AF_INET 25' IP_ADDRESS)
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'CONNECT',R
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '220' THEN
CALL HANDLE_ERROR 'NO 220 MESSAGE',DATA
R = WRITE_SOCKET('HELO 'SMTPHELO || CRLF)
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '250' THEN
CALL HANDLE_ERROR 'NO 250 MESSAGE',DATA
R = WRITE_SOCKET('MAIL FROM: <'FROMEMAIL'>'CRLF)
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '250' THEN
CALL HANDLE_ERROR 'NO 250 MESSAGE',DATA
R = WRITE_SOCKET('RCPT TO: <' || TOADDR || '>' || CRLF)
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '250' THEN
CALL HANDLE_ERROR 'NO 250 MESSAGE',DATA
R = WRITE_SOCKET('DATA'CRLF)
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '354' THEN
CALL HANDLE_ERROR 'NO 354 MESSAGE',DATA
R = WRITE_SOCKET('FROM: 'FROMNAME' <'FROMEMAIL'>' || CRLF)
R = WRITE_SOCKET('TO: ' || TOADDR || CRLF)
R = WRITE_SOCKET('SUBJECT: ' || SUBJECT || CRLF || CRLF)
R = WRITE_SOCKET(BODY)
R = WRITE_SOCKET(END_OF_MESSAGE)
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '250' THEN
CALL HANDLE_ERROR 'NO 250 MESSAGE',DATA
R = WRITE_SOCKET('QUIT'CRLF)
DATA = READ_SOCKET( )
IF SUBSTR(DATA,1,3) /= '221' THEN
CALL HANDLE_ERROR 'NO 221 MESSAGE',DATA
R = SOCKET('CLOSE',SOCKET_ID)
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'CLOSE',R
R = SOCKET('TERMINATE','EMAIL')
IF WORD(R,1) /= 0 THEN
SAY 'ERROR : TERMINATE 'R
EXIT
HANDLE_ERROR :
PARSE ARG TYPE,TEXT
SAY 'ERROR : ' TYPE
IF TEXT /= '' THEN
SAY TEXT
IF INITIALIZED THEN
DO
SAY SOCKET('SOCKETSETSTATUS')
SAY SOCKET('TERMINATE','EMAIL')
END
EXIT
INITIALIZE :
TRUE = 1
FALSE = 0
INITIALIZED = FALSE
CRLF = '0D25'X
END_OF_MESSAGE = '0D254B0D25'X
EXPOSE_VARIABLES = 'SOCKET_ID'
R = SOCKET('INITIALIZE','EMAIL')
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'INITIALISE',R
R = SOCKET('GETHOSTBYNAME',SMTPSERVER)
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'GETHOSTBYNAME',R
IP_ADDRESS = WORD(R,2)
R = SOCKET('SOCKET',2,'STREAM','0')
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'SOCKET',R
ELSE
SOCKET_ID = WORD(R,2)
R = SOCKET('SETSOCKOPT',SOCKET_ID,'SOL_SOCKET','SO_ASCII','ON')
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'SETSOCKOPT',R
INITIALIZED = TRUE
RETURN
WRITE_SOCKET : PROCEDURE EXPOSE (EXPOSE_VARIABLES)
PARSE ARG DATA
R = SOCKET('WRITE',SOCKET_ID,DATA)
IF WORD(R,1) /= 0 THEN
CALL HANDLE_ERROR 'WRITE'
RETURN (R)
READ_SOCKET : PROCEDURE EXPOSE (EXPOSE_VARIABLES)
R = SOCKET('READ',SOCKET_ID)
PARSE VAR R SRC . DATA
IF SRC /= 0 THEN
CALL HANDLE_ERROR 'READ',R
RETURN (DATA)
-----------------------------------

0 new messages