This code can send any arbitary text via standard eMail systems using the Simple Mail Transfer protocol (SMTP).
Recommended reading includes:-
RFC_821 |
Simple Mail Transfer Protocol |
RFC_822 |
ARPA Internet Text Messages |
1 value smtpdiags? \ -- n
Set this non-zero to get diagnostic information.
#200 equ SMTPwait \ -- ms
Number of milliseconds to wait for an SMTP response from
the server. If you are using a slow connection you may
have to increase this value.
#256 equ MAXRXSIZE \ -- n
Size of the response buffer for messages from the SMTP
server.
MAXRXSIZE buffer: SMTPin \ -- addr
The SMTP receive buffer.
: SMTP::Wait \ hsock --
Wait for a response from the server for up to SMTPWAIT
milliseconds.
: SMTP::Error? \ hsock -- flag
Read a response back from the SMTP server via the
supplied socket and return a TRUE flag if the server's response
indicates an error.
: SMTP::Connect \ ipaddr port# -- hsocket|0
Attempt to create a socket and connect to an SMTP Server.
IPADDR is an ipaddress and PORT# is the requested port.
SMTP Servers are almost always found on port 25 (decimal).
: SMTP::Disconnect \ hsock --
Disconnect from a SMTP discussion by closing our socket.
: (SMTPWrite) \ hsock c-addr u --
Write a buffer out via a socket.
: SMTP::Write \ hsock c-addr u --
Write a buffer out via a socket. Used to send text strings to the
SMTP Server.
create crlf$ \ -- addr
A counted string holding a CR/LF pair
: (SMTP::WriteLn) \ hsock c-addr len mode --
As 'SMTP::Write' but followed by a CR/LF pair. Mode is
a TCP flag which is normally 0, but is set to TCP_PSH
by SMTP::WRITEFIELD below.
: SMTP::WriteLn \ hsock c-addr u --
As 'SMTP::Write' but followed by a CR/LF pair.
: SMTP::WriteField \ hsock field-addr field-len val-addr val-len -- flag
Write a 'field' to the SMTP server. In this case a 'field' consists
of a 'field name' and a 'text value' followed by an EOL. Any field
written prompts the server to make a response which is checked for
an error condition to form the return flag.