Previous Chapter | Next Chapter | Up | Next Section | Contents

Sending Mail: the dtml-sendmail tag

The dtml-sendmail tag is used to send an electronic message using the Simple Mail Transport Protocol (SMTP). Unlike other DTML tags, the dtml-sendmail tag does not cause any text to be included in output. Figure 14 shows a DTML document, named SendFeedback , which uses the dtml-sendmail tag to send information collected in a feedback form (figure 15). The dtml-sendmail tag requires numerous pieces of information that are specified by dtml-sendmail tag attributes, shown in Table 28. At minimum, either a Zope MailHost object must be specified, or a SMTP host address must be specified using a smtphost attribute. The recipients, sender, and subject information are required, but they may be provided either as dtml-sendmail tag attributes, or using "header" lines15 at the beginning of the message (figure 14).

A sample document that uses the dtml-sendmail tag

<dtml-var standard_html_header>

<dtml-sendmail smtphost="">
To: Product Support <<dtml-var support>>
From: Web Feedback Form <<dtml-var feedback>>
Subject: <dtml-var subject>

<dtml-var body>

Thank you for your input!

<dtml-var standard_html_footer>

A feedback form that collects a subject and body from a user and submits them to the SendFeedback document shown in figure 14.

<dtml-var standard_html_header>

<H2>We want your input!</H2>

<form action=SendFeedback>
Subject: <input type=text name=subject size=40>
<textarea name=body rows=10 cols=50>
<input type=submit value="Send Feedback">

<dtml-var standard_html_footer>

dtml-sendmail tag attributes




A Zope MailHost object that manages Simple Mail Transport Protocol (SMTP) and port information. This attribute is not used if the smtphost attribute is used.


The address of a SMTP server. Mail will be delivered to this server, which will do most of the work of sending mail. This attribute is not used if the mailhost attribute is used.


If the smtphost attribute is used, then the port attribute is used to specify a port number to connect to. If not specified, then port 25 will be used.


A recipient address or a list of recipient addresses separated by commas.


A sender address.


The subject of the message.

The text following the dtml-sendmail tag can and usually does use DTML tags to include data from input forms and Zope objects. In the S endFeedback example in figure 14, the variables support and feedback are supplied from Folder properties and the variables subject and body are supplied from the FeedbackForm Document shown in figure 15.

Previous Chapter | Next Chapter | Up | Next Section | Contents