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:
From: <dtml-var email>
Subject: Feedback on <dtml-var
Name: <dtml-var name>
Email address: <dtml-var email>
URL: <dtml-var URL>
Remote address: <dtml-var
agent: <dtml-var HTTP_USER_AGENT>
feedback was sent
successfully. Thank you for your comments!
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
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.