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 <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.
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: my_mail@my_domain.com 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 )