[Zope] Iterating inside Sendmail
Tino Wildenhain
tino@wildenhain.de
Thu, 21 Nov 2002 22:10:37 +0100
Hi Michael,
just drop DTML for this too and use
Mailhost.send() instead. If you have a recent
Zope, it strips BCC automatically and you only have
to provide it with mailtxt, which is mailheader + 1 free line +
mailbody.
Minimal mailheader is
To: Person <person@target.com>
From: Person <person@source.com>
Subject: what to say...
The simplest way to do this in a loop is to use a Python long string:
msg="""To: %(to)s
From: %(from)s
Subject: Your subject
Hi there,
foobar...
""".replace('\n','\r\n')
The replace stepp changes the line endings from single newline (Unix,
python) to
carriage-return + newline, which is for rfc822 complience.
all_addresses=[{'to':'Person1 <person1@person1.com>,'from':'Me
<myself@me.com>'},
{'to':'Person2 <person2@person2.com>,'from':'Me
<myself@me.com>'},
{'to':'Person1 <person3@person3.com>,'from':'Me
<myself@me.com>'}]
for target in all_addresses:
Mailhost.send(msg % target)
This is untested, but schould give you a starting point.
Does this help?
Regards
Tino Wildenhain
--On Donnerstag, 21. November 2002 13:38 -0700 Michael
<michael@nichestaffing.com> wrote:
> I have put up a small job site for Linux jobs here in N. Colorado. I
> want to offer the option of entering an email address and have job
> postings emailed directly to subscribers as they are posted. I tried
> the example below, but there seems to be a problem iterating inside
> sendmail.
>
> For the time being, I just created a method and manually entered all the
> email addresses in it, ie: Bcc: <dtml-var listNames>, but I would like to
> automate it if possible. Does anyone have any idea on how to approach
> this?
>
> Michael
>
>
> <dtml-with entries>
>
> <dtml-call "REQUEST.set('post_name', post_name)">
> <dtml-call "REQUEST.set('post_type', post_type)">
> <dtml-call "REQUEST.set('post_email', post_email)">
> <dtml-call "REQUEST.set('description', description)">
> <dtml-call "REQUEST.set('company_name', company_name)">
> <dtml-call "REQUEST.set('company_domain', company_domain)">
> <dtml-call "REQUEST.set('position_title', position_title)">
> <dtml-call "REQUEST.set('org_city', org_city)">
> <dtml-call "REQUEST.set('title', post_name+' - '+post_type+' -
> '+position_title)">
>
> <dtml-with "manage_addProduct['NCLJobs']">
> <dtml-call "ncl_jobs_entry_add(_.None, _, NoRedir=1)">
> </dtml-with>
> </dtml-with>
>
> <dtml-sendmail mailhost="MailHost">
> To: linux@jymis.com
> From: linux-jobs@jymis.com
> Bcc:
> <dtml-with listEntries>
> <dtml-in Catalog>
> <dtml-var email_address>
> </dtml-in>
> </dtml-with>
> Subject: Northern Colorado Linux Jobs Autoresponder
> <dtml-mime type=text/plain encode=7bit>
> POSTING TYPE: <dtml-var post_type>
> COMPANY NAME: <dtml-var company_name>
> COMPANY DOMAIN: <dtml-var company_domain>
> CONTACT EMAIL: <dtml-var post_email>
> POSITION TITLE: <dtml-var position_title>
> LOCATION / CITY: <dtml-var org_city>
>
> DESCRIPTION: <dtml-var description>
> </dtml-mime>
> </dtml-sendmail>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )