IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Rexx to send an email without SMTP Server


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Sun Nov 19, 2017 7:59 pm
Reply with quote

Hi,

In my environment I have a requirement to send a Mainframe report through email to users. We don't have SMTP running in our environment.

I have verified some other old forums on this topic and got a Rexx to send an email. But when I execute my Rexx with Trace am getting the below error.

"57 ENOTCONN Socket is not connected"

The below am posting my entire Rexx and Trace output as well.


/* REXX EMAIL */
TRACE 'I'
SMTP_SERVER = 'RBJESS1'
SMTP_FROM = 'T99UXS@DELL.COM'
SMTP_TO = 'T99UXS@DELL.COM'
SMTP_REPLYTO = 'T99UXS@DELL.COM'
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)
SAY STR
PARSE VAR STR SOCKRC DATA_LENGTH SMTP_RESPONSE
MSG= 'HELO ' || SMTP_SERVER || CRLF
STR = SOCKET('SEND', SOCKID, MSG)
STR = SOCKET('RECV', SOCKID, 10000)
SAY STR
/* MAIL MESSAGE */
MSG= 'MAIL FROM:<' || SMTP_FROM || '>' || CRLF
STR = SOCKET('SEND', SOCKID, MSG)
STR = SOCKET('RECV', SOCKID, 10000)
SAY STR
/* REPEAT RCPT TO SECTION TO SEND TO MULTIPLE USERS */
MSG= 'RCPT TO:<' || SMTP_TO || '>' || CRLF
STR = SOCKET('SEND', SOCKID, MSG)
STR = SOCKET('RECV', SOCKID, 10000)
SAY STR
MSG= 'DATA' || CRLF
STR = SOCKET('SEND', SOCKID, MSG)
STR = SOCKET('RECV', SOCKID, 10000)
SAY STR
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() || CRL
STR = SOCKET('SEND', SOCKID, MSG)
MSG = CRLF || '.' || CRLF
STR = SOCKET('SEND', SOCKID, MSG)
STR = SOCKET('RECV', SOCKID, 10000)
SAY STR
/* 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

REXX TRACE OUTPUT : ------------------------------------------------------------------------

3 *-* SMTP_SERVER = 'RBJESS1'
>L> "RBJESS1"
4 *-* SMTP_FROM = 'T99UXS@DELL.COM'
>L> "T99UXS@DELL.COM"
5 *-* SMTP_TO = 'T99UXS@DELL.COM'
>L> "T99UXS@DELL.COM"
6 *-* SMTP_REPLYTO = 'T99UXS@DELL.COM'
>L> "T99UXS@DELL.COM"
7 *-* CRLF = X2C('0D25')
>L> "0D25"
>F> "??"
8 *-* /* SMTP INITIALIZATION */
9 *-* STR = SOCKET('INITIALIZE', DATE(B))
>L> "INITIALIZE"
>L> "B"
>F> "736651"
>F> "0 736651 40 *INET"
10 *-* PARSE VAR STR SOCKRC SUBTASKID MAXDESC TCPIPUSER
>>> "0"
>>> "736651"
>>> "40"
>>> "*INET"
11 *-* STR = SOCKET('SOCKET', 'AF_INET', 'STREAM', 'TCP')
>L> "SOCKET"
>L> "AF_INET"
>L> "STREAM"
>L> "TCP"
>F> "0 1"
12 *-* PARSE VAR STR SOCKRC SOCKID
>>> "0"
>>> "1"
13 *-* STR = SOCKET('SETSOCKOPT', SOCKID, 'SOL_SOCKET', 'SO_ASCII', 'ON')
>L> "SETSOCKOPT"
>V> "1"
>L> "SOL_SOCKET"
>L> "SO_ASCII"
>L> "ON"
>F> "0"
14 *-* SERVER_INFO = 'AF_INET 25 ' || SMTP_SERVER
>L> "AF_INET 25 "
>V> "RBJESS1"
>O> "AF_INET 25 RBJESS1"
15 *-* STR = SOCKET('CONNECT', SOCKID, SERVER_INFO)
>L> "CONNECT"
>V> "1"
>V> "AF_INET 25 RBJESS1"
>F> "2018 ETRYAGAIN Try Again - resolver"
16 *-* STR = SOCKET('RECV', SOCKID, 10000)
>L> "RECV"
>V> "1"
>L> "10000"
>F> "57 ENOTCONN Socket is not connected"
17 *-* SAY STR
>V> "57 ENOTCONN Socket is not connected"
57 ENOTCONN Socket is not connected
18 *-* PARSE VAR STR SOCKRC DATA_LENGTH SMTP_RESPONSE
>>> "57"
>>> "ENOTCONN"
>>> "Socket is not connected"
19 *-* MSG= 'HELO ' || SMTP_SERVER || CRLF
>L> "HELO "
>V> "RBJESS1"
>O> "HELO RBJESS1"
>V> "??"
>O> "HELO RBJESS1??"
20 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "HELO RBJESS1??"
>F> "57 ENOTCONN Socket is not connected"
21 *-* STR = SOCKET('RECV', SOCKID, 10000)
>L> "RECV"
>V> "1"
>L> "10000"
>F> "57 ENOTCONN Socket is not connected"
22 *-* SAY STR
>V> "57 ENOTCONN Socket is not connected"
57 ENOTCONN Socket is not connected
23 *-* /* MAIL MESSAGE */
24 *-* MSG= 'MAIL FROM:<' || SMTP_FROM || '>' || CRLF
>L> "MAIL FROM:<"
>V> "T99UXS@DELL.COM"
>O> "MAIL FROM:<T99UXS@DELL.COM"
>L> ">"
>O> "MAIL FROM:<T99UXS@DELL.COM>"
>V> "??"
>O> "MAIL FROM:<T99UXS@DELL.COM>??"
25 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "MAIL FROM:<T99UXS@DELL.COM>??"
>F> "57 ENOTCONN Socket is not connected"
26 *-* STR = SOCKET('RECV', SOCKID, 10000)
>L> "RECV"
>V> "1"
>L> "10000"
>F> "57 ENOTCONN Socket is not connected"
27 *-* SAY STR
>V> "57 ENOTCONN Socket is not connected"
57 ENOTCONN Socket is not connected
28 *-* /* REPEAT RCPT TO SECTION TO SEND TO MULTIPLE USERS */
29 *-* MSG= 'RCPT TO:<' || SMTP_TO || '>' || CRLF
>L> "RCPT TO:<"
>V> "T99UXS@DELL.COM"
>O> "RCPT TO:<T99UXS@DELL.COM"
>L> ">"
>O> "RCPT TO:<T99UXS@DELL.COM>"
>V> "??"
>O> "RCPT TO:<T99UXS@DELL.COM>??"
30 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "RCPT TO:<T99UXS@DELL.COM>??"
>F> "57 ENOTCONN Socket is not connected"
31 *-* STR = SOCKET('RECV', SOCKID, 10000)
>L> "RECV"
>V> "1"
>L> "10000"
>F> "57 ENOTCONN Socket is not connected"
32 *-* SAY STR
>V> "57 ENOTCONN Socket is not connected"
57 ENOTCONN Socket is not connected
33 *-* MSG= 'DATA' || CRLF
>L> "DATA"
>V> "??"
>O> "DATA??"
34 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "DATA??"
>F> "57 ENOTCONN Socket is not connected"
35 *-* STR = SOCKET('RECV', SOCKID, 10000)
>L> "RECV"
>V> "1"
>L> "10000"
>F> "57 ENOTCONN Socket is not connected"
36 *-* SAY STR
>V> "57 ENOTCONN Socket is not connected"
57 ENOTCONN Socket is not connected
37 *-* THE_SUBJECT = 'THIS IS A TEST #1'
>L> "THIS IS A TEST #1"
38 *-* MSG = 'TO:' SMTP_TO || CRLF ,
|| 'REPLY-TO:' SMTP_REPLYTO || CRLF ,
|| 'SUBJECT:' THE_SUBJECT || CRLF ,
|| 'X-MA
ILER: REXX EXEC ON ZOS' || CRLF
>L> "TO:"
>V> "T99UXS@DELL.COM"
>O> "TO: T99UXS@DELL.COM"
>V> "??"
>O> "TO: T99UXS@DELL.COM??"
>L> "REPLY-TO:"
>O> "TO: T99UXS@DELL.COM??REPLY-TO:"
>V> "T99UXS@DELL.COM"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM"
>V> "??"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??"
>L> "SUBJECT:"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??SUBJECT:"
>V> "THIS IS A TEST #1"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??SUBJECT: THIS IS A TEST #1"
>V> "??"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??SUBJECT: THIS IS A TEST #1??"
>L> "X-MAILER: REXX EXEC ON ZOS"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??SUBJECT: THIS IS A TEST #1??X-MAILER: REXX EXEC ON ZOS"
>V> "??"
>O> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??SUBJECT: THIS IS A TEST #1??X-MAILER: REXX EXEC ON ZOS??"
42 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "TO: T99UXS@DELL.COM??REPLY-TO: T99UXS@DELL.COM??SUBJECT: THIS IS A TEST #1??X-MAILER: REXX EXEC ON ZOS??"
>F> "57 ENOTCONN Socket is not connected"
43 *-* STR = SOCKET('SEND', SOCKID, CRLF)
>L> "SEND"
>V> "1"
>V> "??"
>F> "57 ENOTCONN Socket is not connected"
44 *-* MSG = 'THIS IS A TEST (#1) FROM ' || USERID() || CRLF
>L> "THIS IS A TEST (#1) FROM "
>F> "SRSQ"
>O> "THIS IS A TEST (#1) FROM SRSQ"
>V> "??"
>O> "THIS IS A TEST (#1) FROM SRSQ??"
45 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "THIS IS A TEST (#1) FROM SRSQ??"
>F> "57 ENOTCONN Socket is not connected"
46 *-* MSG = CRLF || '.' || CRLF
>V> "??"
>L> "."
>O> "??."
>V> "??"
>O> "??.??"
47 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "??.??"
>F> "57 ENOTCONN Socket is not connected"
48 *-* STR = SOCKET('RECV', SOCKID, 10000)
>L> "RECV"
>V> "1"
>L> "10000"
>F> "57 ENOTCONN Socket is not connected"
49 *-* SAY STR
>V> "57 ENOTCONN Socket is not connected"
57 ENOTCONN Socket is not connected
50 *-* /* END OF MAIL MESSAGE */
51 *-* /* SMTP TERMINATION */
52 *-* MSG= 'QUIT' || CRLF
>L> "QUIT"
>V> "??"
>O> "QUIT??"
53 *-* STR = SOCKET('SEND', SOCKID, MSG)
>L> "SEND"
>V> "1"
>V> "QUIT??"
>F> "57 ENOTCONN Socket is not connected"
54 *-* STR = SOCKET('CLOSE', SOCKID)
>L> "CLOSE"
>V> "1"
>F> "0"
55 *-* STR = SOCKET('TERMINATE', SUBTASKID)
>L> "TERMINATE"
>V> "736651"
>F> "0 736651"
56 *-* SAY 'EMAIL SENT TO ' SMTP_TO
>L> "EMAIL SENT TO "
>V> "T99UXS@DELL.COM"
>O> "EMAIL SENT TO T99UXS@DELL.COM"
EMAIL SENT TO T99UXS@DELL.COM
57 *-* E[img]XIT[/code]

Its a great help if you can assist me something on this?

Thanks!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Sun Nov 19, 2017 8:18 pm
Reply with quote

Quote:
In my environment I have a requirement to send a Mainframe report through email to users. We don't have SMTP running in our environment.


why did You volunteer to provide a solution all by Yourself

if Your Organisation has the requirement,
then Your Organisation should put in place the proper tools and environment by setting up a proper SMTP environment

a CUT and PASTE script invoking TCP socket services directly is not robust enough for production status
Your script has NO error discovery,diagnostics,recovery
normally for this class of scripts there is 20% of doing work 80% of error discovery,diagnostics,recovery

and will never pass any security revision
(*)

NO... nobody will spend time trying to solve a problem due to an unreasonable requirement

the fact that You are not able to diagnose and solve a connection issue should make You meditate icon_cool.gif

lastly help people who spend their time helping You
by learning the proper forum etiquette that suggest to use the CODE tags when posting code snippets and outputs
Back to top
View user's profile Send private message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Sun Nov 19, 2017 8:46 pm
Reply with quote

Hi Enrico,

Yeah. I am accepting your words. From past two days Am trying to fix this problem. I don't have much exposure to sockets and In case if somebody in this forum might already handled similar kind of error in their experience, Thought they can give some suggestions.


Thanks!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Sun Nov 19, 2017 9:55 pm
Reply with quote

the communication server manuals will provide You with all You might want to know about the error You are facing and the relevant points of REXX socket programming.

You might want also google
IBM REDBOOKS SOCKET PROGRAMMING
or
rexx socket programming examples
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Nov 20, 2017 12:27 am
Reply with quote

I think your problem starts earlier than you think:
Code:
15 *-* STR = SOCKET('CONNECT', SOCKID, SERVER_INFO)
>L> "CONNECT"
>V> "1"
>V> "AF_INET 25 RBJESS1"
>F> "2018 ETRYAGAIN Try Again - resolver"
And every command you issue should do error checking so you find out as quickly as possible where the problem is, which will then direct your troubleshooting.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Nov 22, 2017 1:43 pm
Reply with quote

upendrasri wrote:
...
We don't have SMTP running in our environment.
...
SMTP_SERVER = 'RBJESS1'
...

One of these cannot be correct icon_exclaim.gif
Back to top
View user's profile Send private message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Wed Nov 22, 2017 3:13 pm
Reply with quote

Hi Marso,

I have tried the below Rexx to identify rexx node

/* REXX NODE */
JNODE = SYSVAR('SYSNODE')
SAY ' NODE :' JNODE

Output :-
NODE : RBJESS1
***

But SMTP Server stc is not running in my environment.

Thanks!
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Nov 23, 2017 9:18 pm
Reply with quote

For the 1st time in a long time, Marso has become speechless...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Nov 23, 2017 9:52 pm
Reply with quote

thinking about locking the topic, it' s getting nowhere icon_cool.gif
Back to top
View user's profile Send private message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Thu Nov 23, 2017 10:33 pm
Reply with quote

Hi All.

Am Still working on My Rexx. I am reading manuals and trying to fix my problems .In case if I find anything I will post my results.


Thanks!
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Nov 24, 2017 12:07 pm
Reply with quote

Quote:
But SMTP Server stc is not running in my environment.



Maybe in another environment?
Back to top
View user's profile Send private message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Fri Nov 24, 2017 12:40 pm
Reply with quote

Hi Peter,

Sorry, In case if my words were confusing. Here am explaining the situation.

One of my Client doesn't have SMTP Server stc running in his Lpars. But when I issued SYSNODE Command am able to see Node as RBJESS1.

But now I have got another Rexx from my friend sending an email without using SMTP Server. Its working fine now.

Thanks alot for all your suggestions.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Fri Nov 24, 2017 12:49 pm
Reply with quote

Quote:
... But when I issued SYSNODE Command am able to see Node as RBJESS1.


the SYSNODE info is NOT related to SMTP

Quote:
But now I have got another Rexx from my friend sending an email without using SMTP Server. Its working fine now.


pretty inconsiderate approach to use something You know nothing about and You might not be able to maintain
Back to top
View user's profile Send private message
Kaliragavendran

New User


Joined: 04 Sep 2019
Posts: 3
Location: India

PostPosted: Wed Sep 04, 2019 3:22 pm
Reply with quote

Hi

Can you share me how you send the mail without smtp,can you please share me rexx if possible?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Wed Sep 04, 2019 4:59 pm
Reply with quote

Welcome to the forum.

Don’t tailgate any old topics , start your own and reference this post in that.

Topic needs to be locked.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Run rexx with JCL Job CLIST & REXX 1
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top