Re: [Zope] Conditional dtml-boundary in dtml-sendmail

2008-04-11 Thread Chris Withers

Tom Von Lahndorff wrote:

How is dtml more error-prone than python? I'd imagine that all depends on
who's authoring it.


In this particular example, python's email package has a very OO 
approach to generating emails.


The DTML approach relies on you remembering to put in the right 
statements for the right constituent email parts in the right places.
It's easy to make mistakes and generate emails that won't work with most 
clients.


It's also harder to generate emails with the correct headers (Date, 
Message-ID, etc) than it should be, so you're more likely to pump out 
email that mtas consider to be spam.


The DTML approach also makes attaching files a living hell...

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Conditional dtml-boundary in dtml-sendmail

2008-04-11 Thread Chris Withers

Tom Von Lahndorff wrote:

The email library should be available to use with a Script (Python) and can
be done all within the ZMI.


Yes, I wish it was. I believe that was one of the things I did in the 
MailTemplates product: just make the standard python email package bits 
available in Zope protected code.


Still, if Josef can't get products installed, he's limited to a world of 
suck when it comes to email :-(


cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Conditional dtml-boundary in dtml-sendmail

2008-04-10 Thread Chris Withers

Andreas Jung wrote:


I started shivering while reading your code. We would have written such 
code

five or six years ago - because we had no other choice.
Please use the standard 'email' module of Python...this just works
and you don't need to write such ugly and error-prone DTML
code.


There's also MailTemplates if you're stuck in Zope 2 land:

http://www.simplistix.co.uk/software/zope/mailtemplates

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Conditional dtml-boundary in dtml-sendmail

2008-04-10 Thread Tom Von Lahndorff
The email library should be available to use with a Script (Python) and can
be done all within the ZMI. Otherwise maybe use dtml-try?

On Wed, Apr 9, 2008 at 4:40 PM, Josef Meile [EMAIL PROTECTED] wrote:

 Dear list

 I'm trying to send a multi-part email after having submitted a
 form. In that form, the user will give some basic information
 from him, then he will be able to send at most three files.

 This is my dtml-method to send email after having submitted the
 data:

 dtml-let email=REQUEST.get('aba_email_txt').encode('utf-8')
  name=REQUEST.get('aau_name_txt').encode('utf-8')
  lastName=REQUEST.get('aat_vorname_txt').encode('utf-8')
  company=REQUEST.get('aas_firma_txt').encode('utf-8')
  file1=REQUEST.get('aap_dateien_anhang_dat')
  file2=REQUEST.get('aaq_dateien_anhang_dat')
  file3=REQUEST.get('aar_dateien_anhang_dat')

 dtml-sendmail smtphost=my_host.my_domain.com
 To: [EMAIL PROTECTED]
 From: dtml-email;
 Subject: Anfrage dtml-name; dtml-lastName; - dtml-company;
 Content-Type: text/html; charset=utf-8
 dtml-mime type=text/html; charset=utf-8
 html
  body
Some html code comes here
  /body
 /html
 dtml-boundary type=application/octet-stream disposition=attachment
   filename_expr=file1.filename
 dtml-var file1.read()dtml-boundary type=application/octet-stream
 disposition=attachment
   filename_expr=file2.filename
 dtml-var file2.read()dtml-boundary type=application/octet-stream
 disposition=attachment
   filename_expr=file3.filename
 dtml-var file3.read()/dtml-mime
 /dtml-sendmail
 /dtml-let

 Let's say that the user doesn't submit file3, on that case, zope will
 generate something like this: some_ramdom_id.dat and it will attach
 an empty file. I tried something like this:

 dtml-if file1.filename not in ['', None]dtml-boundary
  type=application/octet-stream disposition=attachment
  filename_expr=file1.filename
 dtml-var file1.read()/dtml-if

 However when I try to save, zope fails and says:

 
 Error Type: Document Template Parse Error
 Error Value: Unexpected tag, for tag dtml-boundary
 type=application/octet-stream disposition=attachment
 filename_expr=file1.filename , on line 215 of sendAnfrage
 

 The only way I found to cope with this was doing a script to validate if a
 file has whether a name or not, then I will return a dictionary like this:
 {'name': real_name_or_dummy_name, 'data': file.read()_or_dummy_text}

 So, I feed the boundary with a dummy file when no file was uploaded. I
 don't
 really like to send dummy files since it may confuse the person receiving
 the emails. Is there any better way of achieving this? Please note that
 since I'm working in the zmi and I'm not the administrator of the machine
 where my page is hosted, I can only use dtml to send mail :-(, thus using
 the python mail library isn't an option on this case.

 Best regards
 Josef

 ___
 Zope maillist  -  Zope@zope.org
 http://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  http://mail.zope.org/mailman/listinfo/zope-announce
  http://mail.zope.org/mailman/listinfo/zope-dev )

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Conditional dtml-boundary in dtml-sendmail

2008-04-10 Thread Tom Von Lahndorff
How is dtml more error-prone than python? I'd imagine that all depends on
who's authoring it.


 On Wed, Apr 9, 2008 at 11:59 PM, Andreas Jung [EMAIL PROTECTED] wrote:

 
 
  --On 9. April 2008 22:40:01 +0200 Josef Meile [EMAIL PROTECTED]
  wrote:
 
   Dear list
  
   I'm trying to send a multi-part email after having submitted a
   form. In that form, the user will give some basic information
   from him, then he will be able to send at most three files.
  
 
  I started shivering while reading your code. We would have written such
  code
  five or six years ago - because we had no other choice.
  Please use the standard 'email' module of Python...this just works
  and you don't need to write such ugly and error-prone DTML
  code.
 
  -aj
  ___
  Zope maillist  -  Zope@zope.org
  http://mail.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists -
   http://mail.zope.org/mailman/listinfo/zope-announce
   http://mail.zope.org/mailman/listinfo/zope-dev )
 
 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Conditional dtml-boundary in dtml-sendmail

2008-04-09 Thread Andreas Jung



--On 9. April 2008 22:40:01 +0200 Josef Meile [EMAIL PROTECTED] wrote:


Dear list

I'm trying to send a multi-part email after having submitted a
form. In that form, the user will give some basic information
from him, then he will be able to send at most three files.


I started shivering while reading your code. We would have written such code
five or six years ago - because we had no other choice.
Please use the standard 'email' module of Python...this just works
and you don't need to write such ugly and error-prone DTML
code.

-aj

pgp4WZlzN2BGk.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )