72
CHAPTER 5. EXAMPLES OF SCHEME SERVLETS
5.6
Automated Email
Our final example of basic servlets demonstrates how to write a servlet that
sends email. Again, here we assume that the library mail.scm has been
preloaded. The code for this library is in the appendix. This library defines
the send mail procedure which is called as follows:
(send mail request TO FROM SUBJECT TEXT)
Here TO, FROM, SUBJECT, and TEXT are strings.
For example, to send mail to to someone@xxyyzz.com from from me@myserver.com
you would write
(send mail
request
"to someone@xxyyzz.com"
"from me@myserver.com"
"This is a test"
{ Cool, this really works and I can include
scheme expressions like this:
[(* 111 111)] is 111 squared! })
The to and from email addresses can come from the servlet parameters (for
sending confirmation email for example). You should avoid using fake return
addresses as this is annoying and the email can often be easily traced back to
you anyway!