× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
Okay. I tried sending them as text files but they were too big together. I
will try sending one at a time.

 <<SNDSMTP.TXT>>


Albert



        -----Original Message-----
        From:   Brad McDaniel [SMTP:BMCDANIEL@ABSBC.ORG]
        Sent:   Friday, September 14, 2001 11:06 AM
        To:     'midrange-l@midrange.com'
        Subject:        RE: using TELNET (in batch mode) to send e-mail

        This message is in MIME format. Since your mail reader does not
understand
        this format, some or all of this message may not be legible.
        --
        [ Picked text/plain from multipart/alternative ]
        Can you send the attachment in another form besides .zip?  My email
filter
        deletes .zip files.

        Thanks,

        Brad

        -----Original Message-----
        From: York, Albert [mailto:albert.york@nissan-usa.com]
        Sent: Friday, September 14, 2001 12:56 PM
        To: 'MIDRANGE-L@midrange.com'
        Subject: FW: using TELNET (in batch mode) to send e-mail


        This message is in MIME format. Since your mail reader does not
understand
        this format, some or all of this message may not be legible.
        --


        I have attached a couple of source files which I developed to send
and
        receive SMTP email.

        Even if they are too specific to use as is, they will demonstrate
the
        principals and can be easily modified.


        Albert York


         <<email.zip>>


        --
        [ email.zip of type application/octet-stream deleted ]
        _______________________________________________
        This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list
        To post a message email: MIDRANGE-L@midrange.com
        To subscribe, unsubscribe, or change list options,
        visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l
        or email: MIDRANGE-L-request@midrange.com
        Before posting, please take a moment to review the archives
        at http://archive.midrange.com/midrange-l.
        _______________________________________________
        This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list
        To post a message email: MIDRANGE-L@midrange.com
        To subscribe, unsubscribe, or change list options,
        visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l
        or email: MIDRANGE-L-request@midrange.com
        Before posting, please take a moment to review the archives
        at http://archive.midrange.com/midrange-l.
--
      * SNDSMTP
      * Send email using SMTP
      *
      * To compile: CRTBNDRPG DFTACTGRP(*NO) BNDDIR(QC2LE)
      *

     FMaillog   o    e             disk
     Fqatmsmtpa if   e           k disk    usropn

     D AF_INET         C                   Const(2)
     D SOCK_STREAM     C                   Const(1)
     D FIONBIO         c                   const(131074)
     D Non_Block_IO    s             10i 0 inz(1)
     D Unused          s             10i 0 INZ(0)
     D SvrAddrLen      S             10u 0 INZ(0)
     D SocketID        S             10i 0 INZ(0)
     D rc              S             10i 0 INZ(0)
     D p               s             10i 0
     D Size            s             10i 0
     D XLateTable      S             10A
     D XLateTblLib     S             10A
     D XlateLen        s              5P 0
     D ReadBuff        s            255
     D RecvCnt         S             10i 0
     D ReadLim         s              3P 0 inz(255)
     D Timeout         s             10u 0 inz(10000000)
     D TenthSecond     s             10u 0 inz(10000)
     D result          s             10i 0
     D MicroSec        s             10i 0
     D RecvBuff        s           1000
     D SendLen         S             10i 0
     D ReadCnt         s             10i 0
     D WaitCode        s              3
     D Time1           s               z
     D Time2           s               z
     D SendBuff        s           1024
     D WaitForData     s              1n   inz('0')
     D ServerParm      s             25    inz('EXCHANGE')
     D Server          s               *   inz
     D hostent_dataP   s               *   inz
     D hostp           s               *   inz
     D char            s              1
     D MsgBuff         s          32000
     D Message         s          16000
     D Namefield       s             64
     D Addressto       s            256
     D command         s              4
     D DayOfTheWeek    s              4
     D DayName         s              3
     D MonthName       s              3
     D MonthArr        s              3    dim(12) CTDATA perrcd(12)
     D TimeStamp       s             64

     D SocketAddr      DS
     D   SAFamilty                    5u 0
     D   SAData                      14a

     D SvrAddress      DS
     D   Svrfamily                    5i 0
     D   Svrport                      5u 0
     D   Svraddr                     10u 0
     D   SvrNull                      8a

     D hostent         ds                  align based(hostP)
     D  h_namePtr                      *
     D  h_aliasesPtr                   *
     D  h_addrType                   10i 0
     D  h_length                     10i 0
     D  h_addrListPtr                  *

     D Hostent_data    ds                  align based(Hostent_dataP)
     D  h_name                      256a
     D  h_aliasesArrp                  *   dim(65)
     D  h_aliasesArr                256a   dim(64)
     D  H_addrArrp                     *   dim(101)
     D  h_addrArr                    10u 0 dim(100)
     D  open_Flag                    10i 0
     D  F0                             *
     D  Filep0                      260a
     D  reserved_0                  150a
     D  f1                             *
     D  filep1                      260a
     D  reserved_1                  150a
     D  f2                             *
     D  filep2                      260a
     D  reserved_2                  150a

      * Socket prototypes
     D GetHostId       PR            10u 0 ExtProc('gethostid')

     D Socket          PR            10i 0 ExtProc('socket')
     D                               10i 0 Value
     D                               10i 0 Value
     D                               10i 0 Value

     D Read            PR            10i 0 ExtProc('read')
     D                               10i 0 Value
     D                                 *   Value
     D                               10i 0 Value

     D Write           PR            10i 0 ExtProc('write')
     D                               10i 0 Value
     D                                 *   Value
     D                               10i 0 Value

     D Connect         PR            10i 0 ExtProc('connect')
     D                               10i 0 Value
     D                                 *   Value
     D                               10u 0 Value

     D Close           PR            10i 0 ExtProc('close')
     D                               10i 0 Value


     D gethostbyname   PR              *   ExtProc('gethostbyname')
     D                                 *   Value

     D ioctl           PR            10i 0 ExtProc('ioctl')
     D                               10i 0 value
     D                               10i 0 value
     D                               10i 0
     D delay           PR            10I 0 ExtProc('usleep')
     D  DelayTime                    10U 0 value

     D                 ds
     D CurrTime                1     14  0
     D  Hour                   1      2
     D  Minute                 3      4
     D  Seconds                5      6
     D  Month                  7      8  0
     D  Day                    9     10
     D  Year                  11     14

     D SplChr          C                   Const(',;:')
     D Blanks          C                   Const('   ')

     C     *entry        plist
     C                   parm                    UserID            8
     C                   parm                    Address           8
     C                   parm                    ToAddr          256
     C                   parm                    FromAddr        256
     C                   parm                    FromName        256
     C                   parm                    SubJect          64
     C                   parm                    Message1       8000
     C                   parm                    Message2       8000
     C                   parm                    DayOfTheWeek
     C                   parm                    ReturnMsg        70

     C                   exsr      SktConnect

     C                   eval      sendbuff   = 'HELO'
     C                   exsr      WriteData
     C                   eval      command   = 'HELO'
     C                   eval      WaitCode = '250'
     C                   exsr      WaitForCode

     C                   eval      sendbuff = 'MAIL FROM:<'
     C                   eval      SendBuff = %trim(SendBuff) + FromAddr
     C                   eval      SendBuff = %trim(SendBuff) + '>'
     C                   exsr      WriteData
     C                   eval      command   = 'MAIL'
     C                   eval      WaitCode = '250'
     C                   exsr      WaitForCode

     C                   exsr      GetAddress
     C                   eval      sendbuff = 'RCPT TO:<'
     C                   eval      SendBuff = %trim(SendBuff) + AddressTo
     C                   eval      SendBuff = %trim(SendBuff) + '>'
     C                   exsr      WriteData
     C                   eval      command   = 'RCPT'
     C                   eval      WaitCode = '250'
     C                   exsr      WaitForCode

     C                   eval      sendbuff   = 'DATA'
     C                   exsr      WriteData
     C                   eval      command   = 'DATA'
     C                   eval      WaitCode = '354'
     C                   exsr      WaitForCode

     C                   movel     FromName      NameField
     C     SplChr:Blanks xlate     NameField     NameField
     C                   eval      sendbuff = 'FROM:'
     C                   eval      SendBuff = %trim(SendBuff) + NameField
     C                   eval      SendBuff = %trim(Sendbuff) + ' <' + FromAddr
     C                   eval      SendBuff = %trim(Sendbuff) + '>'
     C                   exsr      WriteData

     C                   eval      sendbuff = 'TO:'
     C                   eval      SendBuff = %trim(SendBuff) + AddressTo
     C                   exsr      WriteData

     C                   eval      sendbuff = 'SUBJECT:'
     C                   eval      SendBuff = %trim(SendBuff) + Subject
     C                   exsr      WriteData

     C                   time                    CurrTime
     C                   eval      DayName = %subst(DayOfTheWeek:2:3)
     C                   eval      MonthName = MonthArr(Month)
     C                   movel     DayName       TimeStamp
     C     TimeStamp     cat       ',':0         TimeStamp
     C     TimeStamp     cat       MonthName:1   TimeStamp
     C     TimeStamp     cat       Day:1         TimeStamp
     C     TimeStamp     cat       Year:1        TimeStamp
     C     TimeStamp     cat       Hour:1        TimeStamp
     C     TimeStamp     cat       ':':0         TimeStamp
     C     TimeStamp     cat       Minute:0      TimeStamp
     C     TimeStamp     cat       ':':0         TimeStamp
     C     TimeStamp     cat       Seconds:0     TimeStamp
     C     TimeStamp     cat       '-0700':1     TimeStamp
     C     'Date:'       cat       TimeStamp:1   SendBuff
     C                   exsr      WriteData

     C                   exsr      WriteData

     C                   exsr      writeMsg
     C                   exsr      WriteData

     C                   eval      sendbuff   = '.'
     C                   exsr      WriteData

     C                   eval      command   = 'EOD '
     C                   eval      WaitCode = '250'
     C                   exsr      WaitForCode

     C                   eval      sendbuff   = 'QUIT'
     C                   exsr      WriteData
     C                   eval      command   = 'QUIT'
     C                   eval      WaitCode = '221'
     C                   exsr      WaitForCode

     C                   movel     Addressto     LTOADDR
     C                   movel     FROMADDR      LFROMADDR
     C                   movel     FROMNAME      LFROMNAME
     C                   movel     SUBJECT       LSUBJECT
     C                   movel     TimeStamp     LDATESENT
     C                   movel     MESSAGE       LMESSAGE
     C                   write     MAILLOGR

     C                   exsr      eoj

      **********************************************************************

     C     Getaddress    begsr

     C                   movel     ToAddr        AddressTo

     C     Userid        ifne      *blanks
     C                   open      qatmsmtpa
     C     smtpkey       klist
     C                   kfld                    Userid
     C                   kfld                    address
     C     smtpkey       chain     qatmsmtpa                          44
     C     *in44         ifne      *on
     C                   move      *blanks       addressto
     C     smtpuid       cat       '@':0         Addressto
     C     addressto     cat       domroute:0    Addressto
     C                   endif

     C                   close     qatmsmtpa
     C                   endif

     C                   endsr

      **********************************************************************

      * Write data to the socket
     C     WriteData     begsr

      * Find the length if not specified
     C     SendBuff      ifne      *blanks
     C     ' '           checkr    SendBuff:256  SendLen
      * Convert to ASCII
     C                   CALL      'QDCXLATE'                           68
     C                   PARM      SendLen       XlateLen
     C                   PARM                    SendBuff
     C                   PARM      'QASCII'      XLateTable
     C                   PARM      'QSYS'        XLateTblLib

     C                   else
     C                   move      *zeros        SendLen
     C                   endif

      * Append CR and LF
     C                   add       1             SendLen
     C                   eval      %subst(SendBuff:SendLen:1) = x'0D'
     C                   add       1             SendLen
     C                   eval      %subst(SendBuff:SendLen:1) = x'0A'

      * Write to the socket
     C                   eval      rc = Write(SocketID:%addr(SendBuff):SendLen)

     C                   move      *blanks       SendBuff
     C                   move      *zeros        SendLen

     C                   endsr

      **********************************************************************

     C     WriteMsg      begsr

     C                   movel     Message1      Message
     C                   move      Message2      Message
     C                   eval      MsgBuff = %trim(Message) + '|'
     C     ' '           checkr    MsgBuff:16000 MsgLen            5 0

     C                   do        MsgLen        MsgPtr            5 0
     C
     C                   eval      char = %subst(MsgBuff:MsgPtr:1)
     C     char          ifeq      '|'
     C     SendBuff      ifeq      '.  '
     C                   movel     '..'          Sendbuff
     C                   endif
     C                   exsr      WriteData
     C                   iter
     C                   endif

     C                   add       1             SendLen
     C                   eval      %subst(SendBuff:SendLen:1) = char
     C     SendLen       ifge      1000
     C                   exsr      WriteData
     C                   endif
     C                   enddo

     C                   endsr

      **********************************************************************

     C     WaitForCode   begsr

     C                   exsr      ReadData
     C     WaitCode      scan      RecvBuff                               20
     C     *in20         ifne      *on
     C     command       cat       RecvBuff:1    ReturnMsg
     C                   exsr      EOJ
     C                   endif

     C                   endsr

      **********************************************************************

     C     ReadData      begsr

     C                   move      *blanks       RecvBuff
     C                   move      *zeros        RecvCnt
     C                   time                    Time1

     C     *on           doweq     *on

      * Read data from the socket
     C                   move      *blanks       ReadBuff
     C                   eval      ReadCnt =
     C                             Read(SocketID:%addr(ReadBuff):ReadLim)
     C                   move      *off          *in10

      * Have received data
     C     ReadCnt       ifgt      0

     C     x'0D'         scan      ReadBuff                               10

      * Convert to EBCDIC
     C                   CALL      'QDCXLATE'                           68
     C                   PARM      ReadCnt       XlateLen
     C                   PARM                    ReadBuff
     C                   PARM      'QEBCDIC'     XLateTable
     C                   PARM      'QSYS'        XLateTblLib

      * Add to receive buffer
     C                   eval      %subst(RecvBuff:RecvCnt+1:ReadCnt) = ReadBuff
     C                   eval      RecvCnt = RecvCnt + ReadCnt

     C     *in10         ifeq      *on
     C                   leave
     C                   endif

      * Get next buffer
     C                   iter
     C                   endif

      * No data in the read buffer

      * Check for timeout
     C                   time                    Time2
     C     Time2         subdur    Time1         MicroSec:*ms
     C     MicroSec      ifgt      Timeout
     C                   leave
     C                   endif

      * Wait a tenth of a second before trying again
     C                   eval      result = delay(TenthSecond)

     C                   enddo

     C                   endsr

      **********************************************************************

      * Connect to the telnet server on the AS/400

     C     SktConnect    begsr

      * Set socket attributes
     C                   eval      SocketID = Socket(AF_INET:SOCK_STREAM:UNUSED)
     C     SocketID      iflt      0
     C                   exsr      Eoj
     C                   ENDIF

     C                   eval      serverparm = %trim(serverparm) + x'00'
     C                   eval      server = %addr(serverparm)
     C                   eval      hostp = gethostbyname(server)
     C                   eval      hostent_dataP = h_namePtr
     C                   eval      svrAddr = h_addrArr(1)

     C                   eval      Svrfamily = AF_INET
     C                   eval      Svrport  = 25
     C                   eval      SvrNull   = X'0000000000000000'
     C                   eval      SvrAddrLen= %Size(SvrAddress)
     C                   eval      rc = Connect(SocketID:%addr(SvrAddress):
     C                             SvrAddrLen)
     C     rc            iflt      0
     C                   exsr      Eoj
     C                   endif

      * Set the socket for non-blocking I/O
     C                   eval      rc = ioctl(SocketID:FIONBIO:Non_Block_IO)
     C     rc            iflt      0
     C                   exsr      Eoj
     C                   ENDIF

     C                   exsr      WaitForCode

     C                   endsr

      **********************************************************************

      * End of job
     C     Eoj           begsr

     C                   eval      rc = close(SocketID)
     C                   eval      *INLR = *ON
     C                   return

     C                   endsr
     C*********************************************************************
**
JanFebMarAprMayJunJulAugSepOctNovDec



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.