Common Lisp Package: SMTP4CL

README:

FUNCTION

Public

CALL-WITH-SMTP-CONNECTION (PROC &KEY (SERVER *SMTP-SERVER*) (PORT *SMTP-PORT*))

Make that initial connection to the mail SERVER returning a socket connected to it and signaling an error if it can't be made

SEND-MESSAGE (FROM TO MESSAGE-BODY &KEY CC BCC SUBJECT REPLY-TO HEADERS (SERVER *SMTP-SERVER*) (PORT *SMTP-PORT*))

Sends a message via the mail SERVER. FROM is the address to be given as the sender. TO can be a string or a list of strings naming recipients. MESSAGE-BODY is the message to be sent; it can be a string, or anything else that can be promoted to a MIME-PART; it should not contain headers. CC and BCC can either be a string or a list of strings naming recipients. All CCs and BCCs are sent the message but the BCCs aren't included in the message header. REPLY-TO's value is a string and, if present, a Reply-To header will be created. HEADERS is an alist of symbol and strings. These are header lines added to the header build to be sent out. Example: ((:x-foo . "bar") (:x-friends . "foo bar foobar"))

SEND-VIA-SMTP (FROM RECIPIENTS MESSAGES &KEY (SERVER *SMTP-SERVER*) (PORT *SMTP-PORT*))

This is the low level version of `SEND-MESSAGE'. It doesn't build a header, so MESSAGES should contain one (if not then the MTA may build one for you). Each message in MESSAGES can be a string, a pathname or an input-stream. RECIPIENTS is a list of strings and each string should be in RFC822 format ("foo@bar.com")

Undocumented

FEED-SMTP-SERVER-WITH-MESSAGE (SOCK FROM RECIPIENTS MESSAGE)

Private

EXPECT (STREAM CODE &OPTIONAL ERROR-MSG)

Wait for a result CODE from STREAM and generate an ERROR-MSG error if we receive something else

SMTP-COMMAND (STREAM &REST FORMAT-ARGS)

Send a command to the SMTP server. Command is built using FORMAT-ARGS

SMTP-COMMAND-OR-FAIL (STREAM EXPECTED-RESULT-CODE &REST FORMAT-ARGS)

Send through stream the SMTP command specified by FORMAT-ARGS which are formatted, guess, how, with FORMAT. Generate an error if the SMTP command didn't yield the EXPECTED-RESULT-CODE

WAIT-FOR-RESPONSE (STREAM)

Read the response of the smtp server, collect it in a string. Return three values: response-class whole-response-string response-code

WRITE-CRLF (STREAM)

Terminate a line according to SMTP protocol. That is, with a CR-LF

Undocumented

WRITE-SMTP-LINE (LINE STREAM)

MACRO

Public

WITH-SMTP-CONNECTION ((VAR &REST KEYS) &BODY BODY)

Execute BODY within the lexical scope of VAR which is bound to a socket connected to a SMTP server. KEYS arguments are those supported by CALL-WITH-SMTP-CONNECTION.

Private

WITH-INPUT-FROM ((VAR OBJECT) &BODY BODY)

Generalized macro to read from objects of different types. OBJECT can be anything that has a MAKE-STREAM-FROM defined on. VAR is bound to an input stream from OBJECT and execute BODY in that lexical scoping. On exit of this block the stream is closed.

GENERIC-FUNCTION

Public

Undocumented

MAKE-STREAM-FROM (OBJECT)

WRITE-MESSAGE-TO-SMTP-SERVER (MESSAGE SOCKET)

VARIABLE

Public

*SMTP-DEBUG*

Either nil (no debug output is performed), t (*standard-output*) or an output stream

*SMTP-PORT*

The SMTP port number. Normally 25.

*SMTP-SERVER*

Name of the default SMTP server to be used to send email messages.

CONSTANT

Private

Undocumented

+MAILER-NAME+