[Zope] Sendmail examples

Gregory Haley ghaley@venaca.com
Mon, 23 Oct 2000 10:19:12 -0400


steve smith wrote:
> 
> Anyone have any good, real-world examples using DTML-Sendmail tags? Would
> especially appreciate examples integrating SQL queries.
> 

hi steve.

one of the worst things with zope sendmail is that you cannot indent
things the way you might with clean coding use.  but, you can use some
very nice sql calls within you sendmail, including appropriate
indentation.

below is a sendmail method that i use to read a string of email address
from a mysql database, and the text of the email from a second database,
which gets parsed via an external python script (to parse the string of
text into lines of <= 75 chars, otherwise the text gets sent as single
lines).  also, it checks for non-existent email addresses or missing
names (the database is a list of people and companies, whether connected
to the net or not).

it may not be the most efficient, but it works; and any suggestions as
to making it more efficient will be most appreciated.

ciao!
greg.

venaca.com

********************************** clip
************************************

<dtml-var standard_html_header>
<p>
  <dtml-in get_group>
    <dtml-call "REQUEST.set('counter',2)">
    <dtml-let resp_num=sequence-item resp_x=sequence-index>
      <dtml-call "REQUEST.set('counter',resp_x)">
      <dtml-call "REQUEST.set('resp_numx',resp_num)">
      <dtml-if "resp_numx <> ''">
          <dtml-let resp_ct=sequence-item resp_y=sequence-index>
            <dtml-if "resp_y == counter">
              <dtml-in get_prs>
                <dtml-call "REQUEST.set('pr_num',
strip_blank(pr_id)[:-1])">
                <dtml-if "pr_num == selection">
                  <dtml-call "REQUEST.set('z_subject', pr_subject)">
                  <dtml-call "REQUEST.set('z_title',title)">
                  <dtml-call "REQUEST.set('msg',pr_content)">
<dtml-if "primary_email <> '' and primary_name <> ''">
<dtml-sendmail mailhost="MailHost"> 
To:  <dtml-var primary_name> <<dtml-var primary_email>>
From: <gbehrens@venaca.com> 
Subject: <dtml-var z_subject>

<dtml-var z_title>

<dtml-in "clean_content(msg)">
<dtml-var sequence-item>
</dtml-in>
</dtml-sendmail>

<dtml-elif "primary_name == ''">
<dtml-sendmail mailhost="MailHost"> 
To:  <<dtml-var primary_email>>
From: <monty@blah.blah> 
Subject: <dtml-var z_subject>

<dtml-var z_title>

<dtml-in "clean_content(msg)">
<dtml-var sequence-item>
</dtml-in>
</dtml-sendmail>
</dtml-if>
                </dtml-if>
              </dtml-in>
            </dtml-if>
          </dtml-let>      
      </dtml-if>
    </dtml-let>
</dtml-in>
<dtml-var standard_html_footer>