Re: [Zope] Conditional dtml-boundary in dtml-sendmail
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 <lists@zopyx.com> wrote:
--On 9. April 2008 22:40:01 +0200 Josef Meile <jmeile@hotmail.com> 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 )
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
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. Yes, that's what I hate from the dtml thing; it looks ugly :-(
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. Actually, I did several mistakes: first, if you include a blank line just after finishing defining the email settings, ie: "To, From, Content-Type, etc, you will get your email, but in a format that you can't read.
The second problem was with the unicode: first I got the characters wrong on the email subject, but on the mail's body were ok, then I change something and got them good on the subject, but on the body non-ascii characters were dropped. After lots of testing, I finally saw that you have to define content-type everywhere: on the mail headers and also on the text-mime contents. Then you have to encode all your strings to utf-8.
The DTML approach also makes attaching files a living hell... Yep, I agree on this. You can't dynamically set the number of attachments and even if you don't submit a file on your form, zope will send an empty file with a strange name.
Well, I guess I will do an external method on my own server and then try to convince the people owning the machine where the page is hosted to include it. Otherwise, my last resouce would be to embebbed the content on a iframe or call an external link to my server. Thanks anyways for your replies. Best regards Josef
Josef Meile wrote:
Well, I guess I will do an external method on my own server and then try to convince the people owning the machine where the page is hosted to include it.
You could do a lot worse that using MailTemplates: http://www.simplistix.co.uk/software/zope/mailtemplates It's a stable piece of software that's been around for a few years now and will let you do lots of useful mail-related things without having to install further code on the server filesystem... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (3)
-
Chris Withers -
Josef Meile -
Tom Von Lahndorff