Note: This is taken from the Chicken Wiki, where a more recent version could be available.
Send e-mails using the SMTP protocol (RFC821).
Errors triggered by invalid or negative replies from the SMTP server are signalled by raising a compund condition of the kinds exn and smtp. The error code of a smtp condition can be accessed with the code property.
<procedure>(smtp:connect HOSTNAME DOMAINNAME [VERBOSE [PORT]])</procedure>
Connects to the server HOSTNAME using the SMTP protocol and identifies this client with DOMAINNAME. If the optional argument VERBOSE is given and not #f, then a protocol of the communication with the server is written to the value of (current-error-port). PORT specifies the port-number and defaults to 25.
This procedure returns an object representing the SMTP session.
Closes the connection identified by the session object SMTP.
Returns #t if X is an SMTP session object, or #f otherwise.
<procedure>(smtp:open SMTP FROM TO1 TO2...)</procedure>
Creates a message, where FROM and TO1 TO2... are strings representing the addresses of the sender and the receiver(s), respectively. This procedure returns an output-port that accepts text which is stored as the body of the message. Note that no default headers (other than "From:" and "Date:") are generated. Normally all headers (like "Subject:", etc.) are written first, followed by a completely blank line, followed by the body of the message.
It is not possible to call smtp:open before the port returned by a previously invoked call has been closed.
<examples><example> <init>(use smtp)</init> <expr> (define s (smtp:connect "smtp.your-isp.net" (get-host-name))) (define p (smtp:open s "firstname.lastname@example.org" "email@example.com")) (display "Subject: How are you?\r\n\r\nSo, how are you then?\r\n\n" p) (close-output-port p) (smtp:disconnect s) </expr> </example></examples>
Copyright (c) 2003-2008, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.