-----Original Message----- From: Paulo Eduardo Neves [mailto:neves@inf.puc-rio.br] Sent: Friday, 16 April 1999 12:06 To: Jay, Dylan Cc: 'Michel Pelletier'; 'zope@zope.org' Subject: Re: [Zope] = replaced with == in sendmail!!!!!
"Jay, Dylan" wrote:
I couldn't get it to work but I'm pretty sure it wouldn't anyway. I had a look at the MailHost code and found some quoting stuff that if I knew more about python I might be able to do work out the problem with.
I've just managed to send accend chars (iso8859-1) in an email. I had to add some headers to the message to make it work. Adding it made the mail client interpret correctly the email. Probably everything will be ok if you also use them.
Here is:
<!--#sendmail mailhost="mailhost"--> From: Myself <me@here.com> To: Somebody <she@somewhere.com> Subject: Hi! Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
1+1=2 <!--#/sendmail-->
Try it and see if it works.
Maybe these headers (content-type and enconding) should be added by default.
In fact looking at the code in MailHost.py again, these headers are already added. Is the quoting going wrong or is are the headers wrong or is it the email client? bfile = StringIO(body) mo=rfc822.Message(bfile) for k, v in mo.items(): self.conn.send('%s: %s\015\012' % (string.capitalize(k), v)) # Add some Mime headers if not present if not mo.has_key('Mime-Version'): self.conn.send('Mime-Version: 1.0\015\012') if not mo.has_key('Content-Type'): self.conn.send( 'Content-Type: text/plain; charset="iso-8859-1"\015\012') if not mo.has_key('Content-Transfer-Encoding'): self.conn.send( 'Content-Transfer-Encoding: quoted-printable\015\012') self.conn.send('\015\012') body=bfile.read() body=self.singledots.sub('..', body) body=string.replace(body, '\r\n', '\n') body=string.replace(body, '\r', '\n') body=encode(body, 0) body=string.replace(body, '\n', '\015\012') self.conn.send(body) self.conn.send("\015\012.\015\012") self._check('354') def _close(self): self.conn.send("quit\015\012") self.conn.close() ESCAPE = '=' MAXLINESIZE = 76 HEX = '0123456789ABCDEF' def needsquoting(c, quotetabs): if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') def quote(c): if c == ESCAPE: return ESCAPE * 2 else: i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] def encode(input, quotetabs): """Encode a string to Quoted-Printable""" output = '' for line in string.split(input, '\n'): new = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output = output + new + ESCAPE + '\n' new = '' new = new + c prev = c if prev in (' ', '\t'): output = output + new + ESCAPE + '\n\n' else: output = output + new + '\n' return output def decapitate(message): # split message into headers / body mfile=StringIO(message) mo=rfc822.Message(mfile) hd={} hd['to']=[] for header in (mo.getaddrlist('to'), mo.getaddrlist('cc')): if not header: continue for name, addr in header: hd['to'].append(addr) hd['from']=mo.getaddr('from')[1] hd['subject']=mo.getheader('subject') or "No Subject" return hd, mfile.read()
"Jay, Dylan" wrote:
From: Paulo Eduardo Neves [mailto:neves@inf.puc-rio.br] I've just managed to send accend chars (iso8859-1) in an email. I had to add some headers to the message to make it work. Adding it
...
Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ... In fact looking at the code in MailHost.py again, these headers are already added.
Buh! I haven't even tried to send accented chars in an email without changing the headers. I looks like people at DC borrowed Guido's time machine to satisfy our desires:-) Just the subject line isn't correctly quoted. :-( In other email:
def quote(c): i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16]
You are right changing quote solved this problem. regards, -- Paulo Eduardo Neves PUC-Rio de Janeiro Pager: Central: 292-4499 cod. 213 99 64 ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
At 09:01 16/04/99 , Paulo Eduardo Neves wrote:
"Jay, Dylan" wrote:
From: Paulo Eduardo Neves [mailto:neves@inf.puc-rio.br] I've just managed to send accend chars (iso8859-1) in an email. I had to add some headers to the message to make it work. Adding it
...
Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ... In fact looking at the code in MailHost.py again, these headers are already added.
Buh! I haven't even tried to send accented chars in an email without changing the headers. I looks like people at DC borrowed Guido's time machine to satisfy our desires:-)
Just the subject line isn't correctly quoted. :-(
In other email:
def quote(c): i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16]
You are right changing quote solved this problem.
Uhhmm... If you had a look at the list archives, you could have seen I am responsible for all this mess. The version of MailHost that comes with 1.10.2 encodes all emails to quoted-printable, using a modified version of the quoted-printable code that comes with Python. This version is based on patches I wrote. Meanwhile however, the MailHost product has been altered by me again, now to make quoting of the body optional, and also offering a choice of different quoting mechanisms. DC has expanded on these latest patches, and has meanwhile developed a <!--#mime--> DTML tag as well, to better support MIME types and encodings. You can use the Public CVS repository to get a copy of the latest version of MailHost. The <!--#mime--> tag can be found at: http://www.zope.org/Download/Prereleases/MIMETools/ -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (3)
-
Jay, Dylan -
Martijn Pieters -
Paulo Eduardo Neves