From nicholas.cole at gmail.com Fri Aug 28 02:25:12 2009 From: nicholas.cole at gmail.com (Nicholas Cole) Date: Thu, 27 Aug 2009 20:25:12 -0400 Subject: [Email-SIG] Ensuring 7 bit encoding Message-ID: I hope that this question has a trivial answer, but that people won't mind me asking it here. I've been googling the subject, but can't quite get a handle on it. What do I need to do to ensure that emails are generated only in 7, not 8-bit encodings? I assume that I need to use email.charset.add_charset , but can't quite work out what incantation to give it. Does anyone have any pointers? Best wishes, Nicholas From mark at msapiro.net Fri Aug 28 02:42:05 2009 From: mark at msapiro.net (Mark Sapiro) Date: Thu, 27 Aug 2009 17:42:05 -0700 Subject: [Email-SIG] Ensuring 7 bit encoding In-Reply-To: Message-ID: Nicholas Cole wrote: > >What do I need to do to ensure that emails are generated only in 7, >not 8-bit encodings? I assume that I need to use >email.charset.add_charset , but can't quite work out what incantation >to give it. Does anyone have any pointers? I'm not sure what it is you're asking. Does this answer your question? >>> import email.message >>> m = email.message.Message() >>> m.set_payload("""A few lines ... of 7-bit text ... ... No high bit characters. ... """, 'us-ascii') >>> print m.as_string() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit A few lines of 7-bit text No high bit characters. >>> -- Mark Sapiro The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan From rdmurray at bitdance.com Fri Aug 28 03:45:39 2009 From: rdmurray at bitdance.com (R. David Murray) Date: Thu, 27 Aug 2009 21:45:39 -0400 (EDT) Subject: [Email-SIG] Ensuring 7 bit encoding In-Reply-To: References: Message-ID: On Thu, 27 Aug 2009 at 17:42, Mark Sapiro wrote: > Nicholas Cole wrote: >> >> What do I need to do to ensure that emails are generated only in 7, >> not 8-bit encodings? I assume that I need to use >> email.charset.add_charset , but can't quite work out what incantation >> to give it. Does anyone have any pointers? > > > I'm not sure what it is you're asking. Does this answer your question? > >>>> import email.message >>>> m = email.message.Message() >>>> m.set_payload("""A few lines > ... of 7-bit text > ... > ... No high bit characters. > ... """, 'us-ascii') >>>> print m.as_string() > MIME-Version: 1.0 > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: 7bit > > A few lines > of 7-bit text > > No high bit characters. > >>>> It probably doesn't, since if that message contains high range characters it will result in an encoding of 8bit: >>> import email.message >>> m = email.message.Message() >>> m.set_payload("""A few lines ... of 8-bit text ... ... One high bit character: ??. ... """, 'us-ascii') >>> print m.as_string() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit A few lines of 8-bit text One high bit character: ??. >>> Since 8bit isn't technically us-ascii, I wonder if this is a bug. With a little experiement and a look at the code, it appears that you will get 7bit clean output as long as you always provide a charset for the input other than us-ascii that the charset module has been told should be encoded using QP or BASE64 (which is true for all of the already registered charsets). EG: this results in 7bit clean output: i>>> import email.message >>> m = email.message.Message() >>> m.set_payload("""A few lines ... of 8-bit text ... ... One high bit character: ??. ... """, 'latin-1') >>> print m.as_string() MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable A few lines of 8-bit text One high bit character: =C2=B2. >>> I suspect this is not a complete answer to the question... --David From stephen at xemacs.org Fri Aug 28 08:05:51 2009 From: stephen at xemacs.org (Stephen J. Turnbull) Date: Fri, 28 Aug 2009 15:05:51 +0900 Subject: [Email-SIG] Ensuring 7 bit encoding In-Reply-To: References: Message-ID: <8763c81ni8.fsf@uwakimon.sk.tsukuba.ac.jp> R. David Murray writes: > >>> import email.message > >>> m = email.message.Message() > >>> m.set_payload("""A few lines > ... of 8-bit text > ... > ... One high bit character: ??. > ... """, 'us-ascii') > >>> print m.as_string() > MIME-Version: 1.0 > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: 8bit > > A few lines > of 8-bit text > > One high bit character: ??. > > >>> > > Since 8bit isn't technically us-ascii, I wonder if this is a bug. This is a bug. From MichaelL at vulcan.com Tue Aug 18 18:07:35 2009 From: MichaelL at vulcan.com (Michael Lesauis) Date: Tue, 18 Aug 2009 16:07:35 -0000 Subject: [Email-SIG] header info in body of message. is this normal? EOM Message-ID: Michael Lesauis, Lab Manager Vulcan Inc. (c) 206-499-1037, (d) 206-342-2189 It takes each of us to make a difference for all of us. ~ Mutcheson