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>
On Thu, Nov 21, 2002 at 01:38:30PM -0700, Michael wrote:
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?
Keep the listNames method, and put the <dtml-with listEntries> code in it. Otherwise, you'd be looking at something like: Bcc: <dtml-with listEntries><dtml-in Catalog><dtml-var email_address></dtml-in></dtml-with> because I think you'll have to keep your email headers on their own lines, with no line breaks in them. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
I tried that earlier using Cc: instead of Bcc: (just so I could see the results on the email header) and I just got an empty field: Date: Thu, 21 Nov 2002 10:29:54 -0700 Message-Id: <200211211729.gALHTs6P029637@dick.jymis.com> To: linux@jymis.com From: linux-jobs@jymis.com Cc: Subject: Northern Colorado Linux Jobs Autoresponder Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="63.173.117.26.99.12932.1037900635.151.23946" Status: RO X-Status: O On Thursday 21 November 2002 01:41 pm, Mike Renfro wrote:
Keep the listNames method, and put the <dtml-with listEntries> code in it. Otherwise, you'd be looking at something like:
Bcc: <dtml-with listEntries><dtml-in Catalog><dtml-var email_address></dtml-in></dtml-with>
because I think you'll have to keep your email headers on their own lines, with no line breaks in them.
On Thu, Nov 21, 2002 at 01:38:30PM -0700, Michael wrote:
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 Lewis Nichestaffing.com Web: http://www.nichestaffing.com Email: mlewis@nichestaffing.com Phone: 970-472-1241 Fax: 970-472-8497 "Whatever you can conceive and believe, you can achieve"
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 )
Thanks Tino, I guess this is where dtml just doesn't cut it. i'm real new to Python, (just learning it), so I'll try working on this for a while and see if it does it or not. I am just confused as to why dtml-in does not work inside of sendmail. I also tried, as Mike suggested, creating another method and moving the [with / in] statement to it and then calling it as Bcc: <dtml-var listNames> and that didn't work either. When I 'viewed' it, it appeared to work fine, ie: email@address1.com email@address2.com email@address.com etc. but not inside of sendmail. Michael On Thursday 21 November 2002 02:10 pm, Tino Wildenhain wrote:
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>
From: "Michael" <michael@nichestaffing.com>
I am just confused as to why dtml-in does not work inside of sendmail.
I've used <dtml-in> inside <dtml-sendmail> several times, and it works. That's not the problem. However, specifying the recipients in the <dtml-sendmail> tag is going to be easier than with Bcc anyway.
I have used it before too, where I'm only looking for a specific address and you're right, that does work. I just can't seem to get it to work when there are multiple addresses. I'm not sure what you are trying to say with:
However, specifying the recipients in the <dtml-sendmail> tag is going to be easier than with Bcc anyway.
Michael On Thursday 21 November 2002 03:13 pm, Lennart Regebro wrote:
I've used <dtml-in> inside <dtml-sendmail> several times, and it works. That's not the problem. However, specifying the recipients in the <dtml-sendmail> tag is going to be easier than with Bcc anyway.
From: "Michael" <michael@nichestaffing.com>
I am just confused as to why dtml-in does not work inside of sendmail.
From: "Michael" <michael@nichestaffing.com>
I'm not sure what you are trying to say with:
However, specifying the recipients in the <dtml-sendmail> tag is going to be easier than with Bcc anyway.
You can sepcify the recipients with a list in the dtml-sendmail tag, thusly: <dtml-sendmail mailto="[kalle@foo.com, biffen@bar.com, banane@frotz.com]"> So if we look at Dylans example, it could be simplified to: <dtml-call "REQUEST.set(my_names, something_that_produces_addresses() )"> <dtml-sendmail mailto=my_names> ... </dtml-sendmail> If you instead specify the recipients as a Bcc-header, all that happens is that the MailHost take the bcc-header and makes it into a mailto list. And first making a list into a string and then making that string into a list seems kinda useless to me. :-) Best Regards Lennart Regebro Torped Strategi och Kommunikation AB
Lennart, I will try this method also, but my question is, will the email addresses appear in the header? I have about 35 addresses right now and I really don't want them visable. Each subsrcriber doesn't need to know who else is subscribed to the list, that's why I was wanting to use Bcc. Michael On Friday 22 November 2002 01:44 am, Lennart Regebro wrote:
From: "Michael" <michael@nichestaffing.com>
I'm not sure what you are trying to say with:
However, specifying the recipients in the <dtml-sendmail> tag is going
to
be easier than with Bcc anyway.
You can sepcify the recipients with a list in the dtml-sendmail tag, thusly:
<dtml-sendmail mailto="[kalle@foo.com, biffen@bar.com, banane@frotz.com]">
So if we look at Dylans example, it could be simplified to:
<dtml-call "REQUEST.set(my_names, something_that_produces_addresses() )"> <dtml-sendmail mailto=my_names> ... </dtml-sendmail>
If you instead specify the recipients as a Bcc-header, all that happens is that the MailHost take the bcc-header and makes it into a mailto list. And first making a list into a string and then making that string into a list seems kinda useless to me. :-)
Best Regards
Lennart Regebro Torped Strategi och Kommunikation AB
-- Michael Lewis Nichestaffing.com Web: http://www.nichestaffing.com Email: mlewis@nichestaffing.com Phone: 970-472-1241 Fax: 970-472-8497 "Whatever you can conceive and believe, you can achieve"
Michael writes:
I will try this method also, but my question is, will the email addresses appear in the header? I have about 35 addresses right now and I really don't want them visable. Each subsrcriber doesn't need to know who else is subscribed to the list, that's why I was wanting to use Bcc. Use "BCC" for them.
You may need Zope 2.6 or a "MailHostFix" you find at "http://zwiki.org" to make BCC work as it should be. Dieter
This isn't a DTML problem, per se. You can't send e-mail that isn't properly formatted... that's your core problem. Unless the variable you render in the BCC field contains a value that conforms with RFC822, you won't get the results you're expecting. Multi-line DTML statements insert line breaks into your output stream... that's not a problem when they're forming HTML, but it will mess up e-mail headers. And when you're sending to multiple recipients (on any header), bear in mind that the correct format is comma delimited, not space delimited. Try something like: <dtml-call "REQUEST.set(my_names, [])"> <dtml-in "something_that_produces_addresses()" prefix=recipient> <dtml-call "my_names.append(recipient_item)"> </dtml-in> and then in <dtml-sendmail ...>, put: Bcc: <dtml-var "','.join(my_names)"> HTH, Dylan At 01:42 PM 11/21/2002, you wrote:
Thanks Tino,
I guess this is where dtml just doesn't cut it. i'm real new to Python, (just learning it), so I'll try working on this for a while and see if it does it or not. I am just confused as to why dtml-in does not work inside of sendmail. I also tried, as Mike suggested, creating another method and moving the [with / in] statement to it and then calling it as Bcc: <dtml-var listNames> and that didn't work either. When I 'viewed' it, it appeared to work fine, ie: email@address1.com email@address2.com email@address.com etc. but not inside of sendmail.
Michael
On Thursday 21 November 2002 02:10 pm, Tino Wildenhain wrote:
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 )
Thanks Dylan, I have to run to a meeting tonight so I'll have to write back later to let you know how it goes. I understand the first call, I'm making an empty list. then I'm bringing the Catalog in and appending the email addresses to the list. The part I'm not sure about is the "prefix=recipient" and (recipient_item). Everything else seems to make sense. The dtml-var makes the list into a string that is comma delimited. Thanks for the info, at least I know what the issue is now. Michael On Thursday 21 November 2002 03:19 pm, Dylan Reinhardt wrote:
This isn't a DTML problem, per se. You can't send e-mail that isn't properly formatted... that's your core problem.
Unless the variable you render in the BCC field contains a value that conforms with RFC822, you won't get the results you're expecting.
Multi-line DTML statements insert line breaks into your output stream... that's not a problem when they're forming HTML, but it will mess up e-mail headers. And when you're sending to multiple recipients (on any header), bear in mind that the correct format is comma delimited, not space delimited.
Try something like:
<dtml-call "REQUEST.set(my_names, [])"> <dtml-in "something_that_produces_addresses()" prefix=recipient> <dtml-call "my_names.append(recipient_item)"> </dtml-in>
and then in <dtml-sendmail ...>, put:
Bcc: <dtml-var "','.join(my_names)">
HTH,
Dylan
At 01:42 PM 11/21/2002, you wrote:
Thanks Tino,
I guess this is where dtml just doesn't cut it. i'm real new to Python, (just learning it), so I'll try working on this for a while and see if it does it or not. I am just confused as to why dtml-in does not work inside of sendmail. I also tried, as Mike suggested, creating another method and moving the [with / in] statement to it and then calling it as Bcc: <dtml-var listNames> and that didn't work either. When I 'viewed' it, it appeared to work fine, ie: email@address1.com email@address2.com email@address.com etc. but not inside of sendmail.
Michael
On Thursday 21 November 2002 02:10 pm, Tino Wildenhain wrote:
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
The prefix attribute of the <dtml-in> tag renames the sequence-specific variables within the loop. Thus: <dtml-in some_list> <dtml-var sequence-index> : <dtml-var sequence-item><BR> </dtml-in> produces the same thing as: <dtml-in some_list prefix=list> <dtml-var list_index> : <dtml-var list_item><BR> </dtml-in> The second form substitutes list_index for sequence-index, list_item for sequence-item, etc. The prefix attribute isn't required for a simple loop, but should (IMO) be considered a best practice. It becomes *necessary* when you nest loops or want to make use of a sequence variable in an expression... in those cases, you'll be glad you're in the habit of using prefix and don't have to figure out why <dtml-var "do_something(sequence-item)"> is unable to bind the name "sequence". (In an expression, "sequence-item" means "the sequence variable minus the item variable" not "the variable called sequence-item") For more info, see the docs for dtml-in. HTH, Dylan At 04:23 PM 11/21/2002, you wrote:
Thanks Dylan,
I have to run to a meeting tonight so I'll have to write back later to let you know how it goes. I understand the first call, I'm making an empty list. then I'm bringing the Catalog in and appending the email addresses to the list. The part I'm not sure about is the "prefix=recipient" and (recipient_item). Everything else seems to make sense. The dtml-var makes the list into a string that is comma delimited. Thanks for the info, at least I know what the issue is now.
Michael
On Thursday 21 November 2002 03:19 pm, Dylan Reinhardt wrote:
This isn't a DTML problem, per se. You can't send e-mail that isn't properly formatted... that's your core problem.
Unless the variable you render in the BCC field contains a value that conforms with RFC822, you won't get the results you're expecting.
Multi-line DTML statements insert line breaks into your output stream... that's not a problem when they're forming HTML, but it will mess up e-mail headers. And when you're sending to multiple recipients (on any header), bear in mind that the correct format is comma delimited, not space delimited.
Try something like:
<dtml-call "REQUEST.set(my_names, [])"> <dtml-in "something_that_produces_addresses()" prefix=recipient> <dtml-call "my_names.append(recipient_item)"> </dtml-in>
and then in <dtml-sendmail ...>, put:
Bcc: <dtml-var "','.join(my_names)">
HTH,
Dylan
At 01:42 PM 11/21/2002, you wrote:
Thanks Tino,
I guess this is where dtml just doesn't cut it. i'm real new to Python, (just learning it), so I'll try working on this for a while and see if it does it or not. I am just confused as to why dtml-in does not work inside of sendmail. I also tried, as Mike suggested, creating another method and moving the [with / in] statement to it and then calling it as Bcc: <dtml-var listNames> and that didn't work either. When I 'viewed' it, it appeared to work fine, ie: email@address1.com email@address2.com email@address.com etc. but not inside of sendmail.
Michael
On Thursday 21 November 2002 02:10 pm, Tino Wildenhain wrote:
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
Dylan, Thank you so much. With a little tweaking, I finally got it working. Here is how I had to do it since I was using the Catalog to produce the addresses. sequence-item does not work with the Catalog, all it does it produce: <mybrains instance at 8b526e0> <mybrains instance at 89c55f8> <mybrains instance at 8a97c18> so I used: <dtml-call "REQUEST.set('my_names', [])"> <dtml-with testList> <dtml-in Catalog> <dtml-call "my_names.append(email_address)"> </dtml-in> </dtml-with> and then your code inside the sendmail tag. Bcc: <dtml-var "','.join(my_names)"> Thanks Again, Michael On Thursday 21 November 2002 06:15 pm, Dylan Reinhardt wrote:
The prefix attribute of the <dtml-in> tag renames the sequence-specific variables within the loop.
Thus:
<dtml-in some_list> <dtml-var sequence-index> : <dtml-var sequence-item><BR> </dtml-in>
produces the same thing as:
<dtml-in some_list prefix=list> <dtml-var list_index> : <dtml-var list_item><BR> </dtml-in>
The second form substitutes list_index for sequence-index, list_item for sequence-item, etc.
The prefix attribute isn't required for a simple loop, but should (IMO) be considered a best practice. It becomes *necessary* when you nest loops or want to make use of a sequence variable in an expression... in those cases, you'll be glad you're in the habit of using prefix and don't have to figure out why <dtml-var "do_something(sequence-item)"> is unable to bind the name "sequence". (In an expression, "sequence-item" means "the sequence variable minus the item variable" not "the variable called sequence-item")
For more info, see the docs for dtml-in.
HTH,
Dylan
At 04:23 PM 11/21/2002, you wrote:
Thanks Dylan,
I have to run to a meeting tonight so I'll have to write back later to let you know how it goes. I understand the first call, I'm making an empty list. then I'm bringing the Catalog in and appending the email addresses to the list. The part I'm not sure about is the "prefix=recipient" and (recipient_item). Everything else seems to make sense. The dtml-var makes the list into a string that is comma delimited. Thanks for the info, at least I know what the issue is now.
Michael
On Thursday 21 November 2002 03:19 pm, Dylan Reinhardt wrote:
This isn't a DTML problem, per se. You can't send e-mail that isn't properly formatted... that's your core problem.
Unless the variable you render in the BCC field contains a value that conforms with RFC822, you won't get the results you're expecting.
Multi-line DTML statements insert line breaks into your output stream... that's not a problem when they're forming HTML, but it will mess up e-mail headers. And when you're sending to multiple recipients (on any header), bear in mind that the correct format is comma delimited, not space delimited.
Try something like:
<dtml-call "REQUEST.set(my_names, [])"> <dtml-in "something_that_produces_addresses()" prefix=recipient> <dtml-call "my_names.append(recipient_item)"> </dtml-in>
and then in <dtml-sendmail ...>, put:
Bcc: <dtml-var "','.join(my_names)">
HTH,
Dylan
At 01:42 PM 11/21/2002, you wrote:
Thanks Tino,
I guess this is where dtml just doesn't cut it. i'm real new to Python, (just learning it), so I'll try working on this for a while and see if it does it or not. I am just confused as to why dtml-in does not work inside of sendmail. I also tried, as Mike suggested, creating another method and moving the [with / in] statement to it and then calling it as Bcc: <dtml-var listNames> and that didn't work either. When I 'viewed' it, it appeared to work fine, ie: email@address1.com email@address2.com email@address.com etc. but not inside of sendmail.
Michael
On Thursday 21 November 2002 02:10 pm, Tino Wildenhain wrote:
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
_______________________________________________ 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 )
-- Michael Lewis Nichestaffing.com Web: http://www.nichestaffing.com Email: mlewis@nichestaffing.com Phone: 970-472-1241 Fax: 970-472-8497 "Whatever you can conceive and believe, you can achieve"
From: "Michael" <michael@nichestaffing.com>
addresses. sequence-item does not work with the Catalog, all it does it produce:
<mybrains instance at 8b526e0> <mybrains instance at 89c55f8> <mybrains instance at 8a97c18>
That *is* working. It returns a list of "brains" that matches the search results.
I will try this method also, but my question is, will the email addresses appear in the header?
Hohum. I checked the source code to be sure, and: 1. If you are using Zope versions before 2.6.0, it will be visible if you use Bcc, but not if you use mailto. That Bcc-headers are visible is definitely a bug, and I fixed it in 2.6.0. However: 2. If you are using Zope 2.6.0 what you use in mailto will be visible in the To-headers. I do consider this a bug, and I'll fix that too unless people protest wildly. :-) Best Regards Lennart Regebro Torped Strategi och Kommunikation AB
participants (7)
-
Dieter Maurer -
Dylan Reinhardt -
Lennart Regebro -
Lennart Regebro -
Michael -
Mike Renfro -
Tino Wildenhain