As you can see, this is a simple feedback form for a Web site. When a user submits it, the information entered into it should be automagically emailed to the site's Webmaster.
How is this done in Zope? Very simple. First, create a new Mail Host object (I've called mine "LocalRelay"), and assign it appropriate values for your SMTP server. Then, create a FeedbackFormProcessor, which uses this Mail Host object to send the contents of the form to a specified email address.
Here's the code:
<dtml-var standard_html_header>
<dtml-sendmail mailhost="LocalRelay">
To:
webmaster@domain.com
From: <dtml-var email>
Subject: Feedback on <dtml-var
SERVER_URL>
Name: <dtml-var name>
Email address: <dtml-var email>
Comment:
<dtml-var comment>
--
URL: <dtml-var URL>
Remote address: <dtml-var
REMOTE_ADDR>
User
agent: <dtml-var HTTP_USER_AGENT>
</dtml-sendmail>
Your
feedback was sent
successfully. Thank you for your comments!
<dtml-var standard_html_footer>
In this case, the <dtml-sendmail> directive is used to tell Zope that the
contents of the block are to be sent out as email via the specified Mail Host. You must ensure that the email message includes "To", "From" and "Subject" headers, or else either Zope or your mail server will barf. In addition to these three mandatory headers, you can also specify additional, optional headers, such as "Cc", "Reply-To" and so on.
Notice how I've included a few built-in variables in the email message. This is useful to provide the site's Webmaster with some additional information on the client used to send the feedback.
In case you have difficulty configuring a Mail Host, you can also use this alternative construction:
Once the email message has been sent, a message is displayed to the user confirming
message delivery.
If you're going to be using a lot of feedback forms, you might want to consider making the recipient email address a property, so that you can refer to it as a variable rather than hard-wiring it into the DTML Document code itself.