The smtp structure provides an client library for the Simple Mail Transfer Protocol, commonly used for sending email on the Internet. This library provides a simple wrapper for sending complete emails as well as procedures for composing custom SMTP transactions.
Some of the procedures described here return an SMTP reply code. For details, see RFC 821.
This emails message body with headers headers to recipients in list to-list, using a sender address from. The email is handed off to the SMTP server running on host; default is the local host. Body is either a list of strings representing the lines of the message body or an input port which is exhausted to determine the message body. Headers is an association lists, mapping symbols representing RFC 822 field names to strings representing field bodies.If some transaction-related error happens, smtp-send-mail signals an smtp-error condition with predicate smtp-error?. More specifically, it raises an smtp-recipients-rejected-error (a subtype of smtp-error) if some recipients were rejected. For smtp-error, the arguments to the signal call are the error code and the error message, represented as a list of lines. For smtp-recipients-rejected-error, the arguments are reply code 700 and an association list whose elements are of the form (loser-recipient code . text) -- that is, for each recipient refused by the server, you get the error data sent back for that guy. The success check is (< code 400).
These three are simple queries of the server as stated in the RFC 821: smtp-expann asks the server to confirm that the argument identifies a mailing list, and if so, to return the membership of that list. The full name of the users (if known) and the fully specified mailboxes are returned in a multiline reply. Smtp-verify asks the receiver to confirm that the argument identifies a user. If it is a user name, the full name of the user (if known) and the fully specified mailbox are returned. Smtp-get-help causes the server to send helpful information. The command may take an argument (details) (e.g., any command name) and return more specific information as a response.
Smtp-connect returns an SMTP connection value that represents a connection to the SMTP server.
These procedures make it easy to do simple sequences of SMTP commands. Smtp-connection must be an SMTP connection as returned by smtp-connect. The transaction arguments must be transactions as returned by the procedures below. Smtp-transactions and smtp-transactions/no-close execute the transactions specified by the arguments.For each transaction,
If the transaction's reply code is 221 or 421 (meaning the socket has been closed), then the transaction sequence is aborted, and smtp-transactions/smtp-transactions/no-close return the reply code and text from that transaction.
If the reply code is an error code (in the four- or five-hundred range), the transaction sequence is aborted, and the fatal transaction's code and text values are returned. Smtp-transactions will additionally close the socket for you; smtp-transactions/no-close will not.
If the transaction is the last in the transaction sequence, its reply code and text are returned.
Otherwise, we throw away the current reply code and text, and proceed to the next transaction.
Smtp-transactions closes the socket after the transaction. (The smtp-quit transaction, when executed, also closes the transaction.)
If the socket should be kept open in the case of an abort, use Smtp-transactions/no-close.
These transactions represent the commands of the SMTP protocol for use in smtp-transactions and smtp-transactions/no-close, i.e. they send the corresponding command along with the argument(s), if any. For details, consult RFC 821.The smtp-quit transaction, in addition to sending a QUIT command to the SMTP server, also closes the socket of its SMTP connection.