superk Advanced
Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Mon Oct 11, 2004 7:46 am Post subject: |
|
|
This is a test program that I use. You can modify it as needed:
Code: |
/* REXX */
smtp_server = 'my.smtp.server.address.com'
smtp_from = 'superk@my.address.com'
smtp_address = 'superk@my.address.com'
smtp_to = 'superk@my.address.com'
smtp_replyto = 'superk@my.address.com'
crlf = x2c('0d25')
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)
Parse Var str sockrc data_length smtp_response
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length smtp_response
msg= 'MAIL FROM:<' || smtp_from || '>' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length smtp_response
msg= 'RCPT TO:<' || smtp_address || '>' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length smtp_response
msg= 'DATA' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length smtp_response
the_subject = 'This is a Test'
msg = 'To:' smtp_to || crlf ,
|| 'Reply-To:' smtp_replyto || crlf ,
|| 'Subject:' the_subject || crlf ,
|| 'X-Mailer: REXX Exec on MVS' || crlf
str = Socket('Send', sockid, msg)
msg = 'Mime-Version: 1.0' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-type: multipart/mixed;' ,
'boundary="Mime.Part.0x0zlrhg"' || crlf
str = Socket('Send', sockid, msg)
msg = 'This is a multi-part message in MIME format.' || crlf
str = Socket('Send', sockid, msg)
msg = '--Mime.Part.0x0zlrhg' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-Type: text/plain; charset="iso-8859-1"' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-Transfer-Encoding: 7bit' || crlf
str = Socket('Send', sockid, msg)
msg = '* ---------------------------- *' || crlf
str = Socket('Send', sockid, msg)
msg = '* ---------------------------- *' || crlf
str = Socket('Send', sockid, msg)
msg = '* ---------------------------- *' || crlf
str = Socket('Send', sockid, msg)
msg = '--Mime.Part.0x0zlrhg' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-Type: text/plain;',
'name=report.txt' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-Transfer-Encoding: 7bit' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-Disposition: attachment;',
'filename=report.txt' || crlf
str = Socket('Send', sockid, msg)
msg = 'Content-Description: report.txt' || crlf
str = Socket('Send', sockid, msg)
msg = crlf
str = Socket('Send', sockid, msg)
msg = ''
Do loop = 1 To 100
msg = msg || 'This is a test record' loop 'of 100' || crlf
End
str = Socket('Send', sockid, msg)
str = Socket('Send', sockid, crlf)
msg = crlf || '.' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length smtp_response
msg= 'QUIT' || crlf
str = Socket('Send', sockid, msg)
str = socket('Close', sockid)
str = socket('Terminate', subtaskid)
Say 'Email sent to ' smtp_to
Exit
|
|
|