sending email on mvs via smtp -or- you’ve got mail! (from the mainframe) -or- sleepless in smtp...

23
Sending Email on MVS Sending Email on MVS via SMTP via SMTP -Or- -Or- You’ve Got Mail! You’ve Got Mail! (from the mainframe) (from the mainframe) -or- -or- Sleepless in SMTP Sleepless in SMTP Jon Gibbens Jon Gibbens [email protected] [email protected]

Post on 21-Dec-2015

227 views

Category:

Documents


2 download

TRANSCRIPT

Sending Email on MVS via Sending Email on MVS via SMTPSMTP

-Or--Or-

You’ve Got Mail! You’ve Got Mail!

(from the mainframe)(from the mainframe)

-or--or-

Sleepless in SMTPSleepless in SMTPJon GibbensJon Gibbens

[email protected]@provista.com

A Familiar Phone A Familiar Phone Conversation?Conversation? ““Hello, this is Jon..”Hello, this is Jon..”

• ““Yes, this is Steve Bigwig here, did my Yes, this is Steve Bigwig here, did my extracts run last night??”extracts run last night??”

““Let me check. <click click> Yes, they Let me check. <click click> Yes, they are done..the job ran last night at 3am”are done..the job ran last night at 3am”• ““Ok, and could you tell me how many Ok, and could you tell me how many

records were on it?”records were on it?” <click click> “ Yeah, 500.”<click click> “ Yeah, 500.”

• ““Thanks”Thanks” Next week..same exact phone call!!!Next week..same exact phone call!!!

IntroductionIntroduction

Need to notify users when certain Need to notify users when certain conditions have been met, such conditions have been met, such as...as...• Reports Printed/ReadyReports Printed/Ready• Files transferredFiles transferred• Jobs completed/failedJobs completed/failed

Provide some kind of automated Provide some kind of automated reporting - ie..send data to someone on reporting - ie..send data to someone on a regular basisa regular basis

How about using Email?How about using Email?

Email can help bridge the Email can help bridge the communication gap between you communication gap between you (the developer) and end users.(the developer) and end users.

The rest of the world uses email to The rest of the world uses email to notify people about things, why not notify people about things, why not you and your MVS-based FOCUS you and your MVS-based FOCUS programs?programs?

Presentation AgendaPresentation Agenda

How does it work?How does it work?• Note Control FileNote Control File

Sample JCL (Inline & Procedure)Sample JCL (Inline & Procedure) Sample FOCEXEC codeSample FOCEXEC code Sending a report via emailSending a report via email Advanced Usage (URL’s, HTML)Advanced Usage (URL’s, HTML) WWW resourcesWWW resources Q & AQ & A

How does it work?How does it work?

In a nutshell:In a nutshell:• 1 - Dynamically create your NOTE CONTROL 1 - Dynamically create your NOTE CONTROL

FILE or use one that you have already FILE or use one that you have already created.created.

• 2 - NOTE CONTROL file contains the “secret 2 - NOTE CONTROL file contains the “secret handshake” as well as your note body text.handshake” as well as your note body text.

• 3 - Send NOTE CONTROL file off to SMTP via 3 - Send NOTE CONTROL file off to SMTP via IEBGENER.IEBGENER.

SMTP allows for sending of email to any SMTP allows for sending of email to any connected Intranet or Internet host.connected Intranet or Internet host.

Note Control File - REQUIRED Note Control File - REQUIRED ELEMENTSELEMENTS(or....What’s the secret (or....What’s the secret handshake?)handshake?)

1. HELO HOST - HOST is name of the MVSHOST 1. HELO HOST - HOST is name of the MVSHOST (defined in SYS1.PARMLIB(IEFSSNxx)(defined in SYS1.PARMLIB(IEFSSNxx)

2. MAIL FROM:<email address> -sender of note2. MAIL FROM:<email address> -sender of note

3. RCPT TO:<email address> - 1 line per email 3. RCPT TO:<email address> - 1 line per email recipient (as many recipients as you want)recipient (as many recipients as you want)

4. DATA - seperator between RCPT TO & SUBJECT4. DATA - seperator between RCPT TO & SUBJECT

5. SUBJECT - subject line of note5. SUBJECT - subject line of note

6. Note Body 6. Note Body

Sample Note Control fileSample Note Control file

•Note Control file generated with FOCUS/Dialogue Manager (using -WRITE statements)

HELO HOST MAIL FROM:<[email protected]> RCPT TO:<[email protected]> DATA SUBJECT: TEST OF MAILING OUT

THIS IS A TEST OF EMAIL :)

JON GIBBENS

JCL section of a procedureJCL section of a procedure

•IEBGENER - copies sequential dataset from any device to any device.•Input step in SYSUT1 - location of Note Control File•Output step in SYSUT2 - passes control to SMTP program

//********************************************************************** //* PS020: EXECUTE IEBGENER PROGRAM TO SEND EMAIL NOTIFICATION VIA SMTP //********************************************************************** //PS020 EXEC PGM=IEBGENER //********************************************************************** //SYSIN DD DUMMY //SYSUT1 DD DSN=&WKPDS..NOTECNTL.TEST,DISP=SHR //SYSUT2 DD SYSOUT=(B,SMTP) //SYSOUT DD SYSOUT=X //SYSPRINT DD SYSOUT=X

JCL with note control file JCL with note control file included inlineincluded inline

//MA#JOGA1 JOB (TEST,MF#1),'JON MAIL TEST',CLASS=9,MSGCLASS=T,// NOTIFY=MF#JOG,USER=MF#JOG //IEBGENER EXEC PGM=IEBGENER //SYSIN DD DUMMY //SYSUT1 DD * HELO HOST MAIL FROM:<[email protected]> RCPT TO:<[email protected]> DATA SUBJECT: TEST OF MAILING OUT

THIS IS A TEST OF EMAIL :)

JON GIBBENS

/* //SYSUT2 DD SYSOUT=(B,SMTP) //SYSOUT DD SYSOUT=X //SYSPRINT DD SYSOUT=X

Sample Note generated by JCLSample Note generated by JCL( as viewed in Exchange)( as viewed in Exchange)

Sample ScenarioSample Scenario

Want to let Steve Bigwig know Want to let Steve Bigwig know when his job ran, and how many when his job ran, and how many records it pulled.records it pulled.

Sample Focexec to follow writes Sample Focexec to follow writes out the # system time & date, and out the # system time & date, and the # of records in a flat file. Also the # of records in a flat file. Also creates our NOTE CONTROL FILE.creates our NOTE CONTROL FILE.

FOCUS code to create FOCUS code to create NOTE Control FileNOTE Control File

Focexec is EMLSAMP1Focexec is EMLSAMP1• Includes a utility I use for creating Includes a utility I use for creating

most of my email related && most of my email related && variablesvariables

This code would go AFTER ‘data This code would go AFTER ‘data extract’ portion of the program.extract’ portion of the program.

Would be part of a JCL Would be part of a JCL job/procedurejob/procedure

-*TABLE FILE <whatever>SUM CNT.ACCOUNTSBY CODE-*-*EMLSAMP1: JONATHAN GIBBENS-*FOCEXEC ABOVE DOES EXTRACT FOR STEVE BIGWIG-*END-* =====================================================-* SET THE SYSTEM TIME VARIABLE-* =====================================================-SET &STIME = ' ';-SET &STIME = HHMMSS(&STIME);-*-* =====================================================-* SET UP 3 BODY LINES FOR EMAIL MESSAGE --* DATE/TIME/RECORDS/LINES-* =====================================================-SET &NEATDATE = EDIT(&YYMD,'9999/99/99');-SET &BODY1 = ' YOUR EXTRACT RAN ON ' | &NEATDATE | ' AT ' |- &STIME;-SET &BODY2 = ' THE NUMBER OF LINES IN YOUR EXTRACT WAS ' |- &LINES;-SET &BODY3 = ' THE NUMBER OF RECORDS IN YOUR EXTRACT WAS '| &RECORDS;-*-* =====================================================-* SET UP THE RECIPIENTS OF THE NOTE, AND THE SUBJECT-* =====================================================-SET &RCPT1='[email protected]';-SET &RCPT2='[email protected]';-SET &SUBJECT = 'FILE EXTRACTS FOR ' | &NEATDATE;-*-*

-***********************************************************-* NOTE CONTROL FILE UTILITY-* JON GIBBENS - PROVISTA SOFTWARE INTL. - [email protected]*-* SET UP && VARIABLES FOR CREATION OF NOTE CONTROL FILE-* NOTE: ALL OF THESE -SETS COULD BE INSIDE OF AN INCLUDE -* FILE FOR CONVENIENCE AND CODE PORTABILITY-**-** INPUTS:-** &RCPT1-5 = UP TO FIVE VALID EMAIL ADDRESSES-** &SUBJECT = THE SUBJECT OF THE NOTE-**-** OUTPUTS: ESSENTIAL VARIABLES FOR AN EMAIL MESSAGE-**-** &HELOLINE = 'HELO HOST' - FIRST LINE OF EMAIL MESSAGE-** WHERE HOST IS THE MAIL SUBSYSTEM-** &RCPTLNE1='RCPT TO:<RPCT1>' FIRST RECIPIENT-** &RCPTLNE2='RCPT TO:<RPCT2>' 2ND RECIPIENT-** &RCPTLNE3='RCPT TO:<RPCT3>' 3RD ""-** &RCPTLNE4='RCPT TO:<RPCT4>' 4TH ""-** &RCPTLNE5='RCPT TO:<RPCT5>' 5TH ""-** &SUBLINE = 'SUBJECT: &SUBJECT'-** &TOEND = '>' - THE END OF THE 'TO' LINE-** &DATALINE = 'DATA' - PUT AFTER 'TO' LINE(s)-** &SUBBEG = 'SUBJECT:' - BEGINNING OF SUBJECT LINE-** &SIGLINE1='THANKS! HAVE A NICE DAY!'-** &BLANKLINE = ' ' - SPACES/BLANKS-**************************************************************-**DEFAULT THE ESSENTIAL ELEMENTS-***************************************************************-DEFAULTS &HELOLINE = 'HELO HOST'-DEFAULTS &TOBEG = 'RCPT TO:<'-DEFAULTS &TOEND = '>'-DEFAULTS &DATALINE = 'DATA'-DEFAULTS &SUBBEG = 'SUBJECT: '-DEFAULTS &RCPT1=' '-DEFAULTS &RCPT2=' '-DEFAULTS &RCPT3=' '-DEFAULTS &RCPT4=' '-DEFAULTS &RCPT5=' '-DEFAULTS &SUBJECT = ' '-DEFAULTS &BLANKLINE = ' '-RUN

EMLSAMP1 Focexec

-*-* -------------------------------------------------------------* SET UP THE RCPT TO: LINES - UP TO 5 PEOPLE CAN BE SENT THE EMAIL-* READ IN THE &RCPT1,&RCPT2,&RCPT3,&RCPT4,&RCPT5 VARIABLES-* OUTPUT IN THE FORMAT: RCPT TO:<EMAIL ADDRESS>-* -------------------------------------------------------------*-SET &RCPTLNE1 = &TOBEG || &RCPT1 || &TOEND;-SET &RCPTLNE2 = &TOBEG || &RCPT2 || &TOEND;-SET &RCPTLNE3 = &TOBEG || &RCPT3 || &TOEND;-SET &RCPTLNE4 = &TOBEG || &RCPT4 || &TOEND;-SET &RCPTLNE5 = &TOBEG || &RCPT5 || &TOEND;-*-* -------------------------------------------------------------* SET UP THE SUBJECT LINE - READ IN &SUBJECT;-* -------------------------------------------------------------*-SET &SUBLINE = 'SUBJECT: ' | &SUBJECT;-********************************************************************-**INSTALLATION SPECIFIC VARIABLES-** &FROMLINE - EMAIL ADDRESS FOR THE SENDER (CAN BE ANY EMAIL-** ADDRESS)-** &SIGLINE1 - LINE TO END THE EMAIL ********************************************************************-*-DEFAULTS &FROMLINE = 'MAIL FROM:<[email protected]>'-DEFAULTS &SIGLINE1 = 'THANKS! HAVE A NICE DAY!!'-DEFAULTS &SIGLINE2 = 'QUESTIONS/PROBLEMS? EMAIL [email protected]'-***********************************************************************-*-* ----------------------------------------------------------------* WRITE OUT THE NOTE CONTROL FILE: NOTECNTL-* NOTE CONTROL FILE IS A FLAT FILE ALLOCATED AS MOD-* FOR SIMPLE NOTES, IT CAN BE FIXED FORMAT, 80 CHARACTERS, 27920 BLKS

-

EMLSAMP1 Focexec-* ----------------------------------------------------------------* =====================================================-* WRITE OUT THE HELOLINE & THE FROM LINE-* =====================================================-*-WRITE NOTECNTL &HELOLINE-WRITE NOTECNTL &FROMLINE-*-* =====================================================-* WRITE OUT THE RECIPIENT(S)-* =====================================================-*-WRITE NOTECNTL &RCPTLNE1-WRITE NOTECNTL &RCPTLNE2-*-* =====================================================-* WRITE OUT THE DATA SEPERATOR & SUBJECT LINE-* =====================================================-*-WRITE NOTECNTL &DATALINE-WRITE NOTECNTL &SUBLINE-*-* =====================================================-* WRITE OUT THE BODY OF THE NOTE-* =====================================================-*-WRITE NOTECNTL &BLANKLINE-WRITE NOTECNTL &BODY1-WRITE NOTECNTL &BODY2-WRITE NOTECNTL &BODY3-WRITE NOTECNTL &BLANKLINE-WRITE NOTECNTL &SIGLINE1-WRITE NOTECNTL &SIGLINE2-*-*-* =========================================================-* END OF JOB EMLSAMP1-* =========================================================

Resulting file from Resulting file from EMLSAMPEMLSAMP

HELO HOST HELO HOST

MAIL FROM:<[email protected]> MAIL FROM:<[email protected]>

RCPT TO:<[email protected]> RCPT TO:<[email protected]>

RCPT TO:<[email protected]> RCPT TO:<[email protected]>

DATA DATA

SUBJECT: FILE EXTRACTS FOR 1999/09/10 SUBJECT: FILE EXTRACTS FOR 1999/09/10

YOUR EXTRACT RAN ON 1999/09/10 AT 16.53.44 YOUR EXTRACT RAN ON 1999/09/10 AT 16.53.44

THE NUMBER OF LINES IN YOUR EXTRACT WAS 27 THE NUMBER OF LINES IN YOUR EXTRACT WAS 27

THE NUMBER OF RECORDS IN YOUR EXTRACT WAS 1000 THE NUMBER OF RECORDS IN YOUR EXTRACT WAS 1000

THANKS! HAVE A NICE DAY!! THANKS! HAVE A NICE DAY!!

QUESTIONS/PROBLEMS? EMAIL [email protected]/PROBLEMS? EMAIL [email protected]

Sending a report via emailSending a report via email

To send a small report (less than the To send a small report (less than the maxiumum line length of your email maxiumum line length of your email client) client) 1. Turn off page-breaks (SET 1. Turn off page-breaks (SET

PAGE=NOPAGE )PAGE=NOPAGE )

2. Put NOTE CONTROL FILE elements into 2. Put NOTE CONTROL FILE elements into your HEADER (ie..HELO,MAIL FROM,RCPT your HEADER (ie..HELO,MAIL FROM,RCPT TO,DATA)TO,DATA)

3. Save file in WP format and then send off to 3. Save file in WP format and then send off to IEBGENER using JCL in examples.IEBGENER using JCL in examples.

Advanced Usage Advanced Usage URLs - Exchange/Outlook or Netscape mail URLs - Exchange/Outlook or Netscape mail

(other mail clients as well) will read any URL’s (other mail clients as well) will read any URL’s you include in your note and will activate you include in your note and will activate themthem• So, if you are doing Intranet type reporting, you can So, if you are doing Intranet type reporting, you can

point users to where the reports are.point users to where the reports are. Can do fancier HTML formatting if include Can do fancier HTML formatting if include

MIME tags and HTML code (example to follow) MIME tags and HTML code (example to follow) • Only really works if email client fully supports Only really works if email client fully supports

HTML, or at least, supports the features that YOU HTML, or at least, supports the features that YOU need.need.

Note Control File with a URLNote Control File with a URLalong with resulting note.along with resulting note.

HELO HOST HELO HOST

MAIL FROM:<[email protected]> MAIL FROM:<[email protected]>

RCPT TO:<[email protected]> RCPT TO:<[email protected]>

DATA DATA

SUBJECT: TEST OF USING URL IN NOTE SUBJECT: TEST OF USING URL IN NOTE

A good site to visit for FUSE-related information A good site to visit for FUSE-related information is: is:

http://www.csuhayward.edu/FOCUS/ncalfuse.htm http://www.csuhayward.edu/FOCUS/ncalfuse.htm

Note Control File with HTMLNote Control File with HTMLalong with resulting note.along with resulting note.

HELO HOST HELO HOST

MAIL FROM:<[email protected]> MAIL FROM:<[email protected]>

RCPT TO:<[email protected]> RCPT TO:<[email protected]>

DATA DATA

SUBJECT: A HTML TEST NOTE SUBJECT: A HTML TEST NOTE

MIME-Version: 1.0MIME-Version: 1.0

Content-type: text/html; charset=“us-ascii”Content-type: text/html; charset=“us-ascii”

<HTML><HTML>

<BODY><BODY>

<H1>Here’s the big header of the note</H1><H1>Here’s the big header of the note</H1>

<P><P>

Hey, here’s an HTML note that will have you seeing Hey, here’s an HTML note that will have you seeing <font face=“Arial” size=“+5” color=red>RED</font><font face=“Arial” size=“+5” color=red>RED</font>

</BODY></BODY>

</HTML></HTML>

WWW ResourcesWWW Resources

Dave’s MVS Mail Page - Dave’s MVS Mail Page - http://users.ticnet.com/davea/mvs/mvsmail http://users.ticnet.com/davea/mvs/mvsmail

Decoding Internet Attachments - Decoding Internet Attachments - http://pages.prodigy.net/michael_santovec/dechttp://pages.prodigy.net/michael_santovec/decode.htm - To find out more about MIME tags, ode.htm - To find out more about MIME tags, and different compatibility issues with different and different compatibility issues with different email clientsemail clients

Questions?Questions?

Download this Download this presentationpresentation

Northern California FUSE Homepage:Northern California FUSE Homepage:

http://www.csuhayward.edu/FOCUS/mvsmail.ppthttp://www.csuhayward.edu/FOCUS/mvsmail.ppt