{"thread":{"id":"43588","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","startedAt":"2006-11-05T19:29:15Z","lastAt":"2006-11-16T17:24:01Z","messageCount":10,"participants":["Catalin Marinas","Karl Hasselström","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"296712","messageId":"eile19$p7r$1@sea.gmane.org","threadId":"43588","inReplyTo":"20061105190400.GC25259@diana.vm.bytemark.co.uk","subject":"Re: [PATCH] Allow hand-editing of patches before sending","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-05T19:29:15Z","receivedAt":"2006-11-05T19:29:15Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Karl Hasselström wrote:\n\n> These are the headers that StGIT uses without my patch -- that is, the\n> headers used to get that error message:\n> \n>   Content-Type: text/plain; charset=utf-8; format=fixed\n>   Content-Transfer-Encoding: 8bit\n> \n> Which is obviously not good enough for some picky part of the SMTP\n> chain.\n\nI think you are missing MIME-Version: header.\n\n[...]\n\n> Well, it added these headers:\n> \n>   MIME-Version: 1.0\n>   Content-Transfer-Encoding: QUOTED-PRINTABLE\n>   Content-Type: TEXT/PLAIN; charset=ISO-8859-1\n> \n> Maybe MIME-Version was the only thing missing? I'll have to try.\n\nMIME-Version _is_ important. I remember that Outlook Express sent news\nmessages without this header, and those posts were either mangled by news\nserver, or news readers didn't parse MIME headers without MIME-Version:\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"297507","messageId":"20061106074532.10376.60478.stgit@localhost","threadId":"43588","inReplyTo":"eile19$p7r$1@sea.gmane.org","subject":"[PATCH] Add a MIME-Version header to e-mails","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-06T07:45:32Z","receivedAt":"2006-11-06T07:45:32Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"From: Karl Hasselström <kha@treskal.com>\n\nThis is required by some mail servers that want to change the transfer\nencoding of the mail.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n---\n\nOK, this is a test to see if adding MIME-Version makes the problem go\naway. I don't have any other way to test this than sending a patch to\nthe list. :-)\n\n stgit/commands/mail.py |   12 +++++-------\n 1 files changed, 5 insertions(+), 7 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex 45f7438..c428d67 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -271,13 +271,11 @@ def __get_signers_list(msg):\n     return addr_list\n \n def __build_extra_headers():\n-    \"\"\"Build extra headers like content-type etc.\n-    \"\"\"\n-    headers  = 'Content-Type: text/plain; charset=utf-8; format=fixed\\n'\n-    headers += 'Content-Transfer-Encoding: 8bit\\n'\n-    headers += 'User-Agent: StGIT/%s\\n' % version.version\n-\n-    return headers\n+    \"\"\"Build extra headers like content-type etc.\"\"\"\n+    return ('MIME-Version: 1.0\\n'\n+            'Content-Type: text/plain; charset=utf-8; format=fixed\\n'\n+            'Content-Transfer-Encoding: 8bit\\n'\n+            'User-Agent: StGIT/%s\\n' % version.version)\n \n def edit_message(msg):\n"},{"id":"298023","messageId":"20061106075634.GA4532@diana.vm.bytemark.co.uk","threadId":"43588","inReplyTo":"20061106074532.10376.60478.stgit@localhost","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-06T07:56:34Z","receivedAt":"2006-11-06T07:56:34Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-11-06 08:45:32 +0100, Karl Hasselström wrote:\n\n> OK, this is a test to see if adding MIME-Version makes the problem\n> go away. I don't have any other way to test this than sending a\n> patch to the list. :-)\n\nAll right, it seems to have worked! When I send patches to myself,\nthey arrive still 8bit-encoded, and when I get them through the list,\nthey have been properly QP-encoded by whatever part of the chain\ndidn't like 8bit.\n\nCatalin, this should replace the QP-encoding patch. (But not the\nRFC2047-encoding patch -- the headers are required to always be ascii,\nif I've not misunderstood something.)\n\nThanks everyone!\n\n-- \nKarl Hasselström, kha@treskal.com\n"},{"id":"297849","messageId":"b0943d9e0611070153s2a52f65k6ed4643e60a144b3@mail.gmail.com","threadId":"43588","inReplyTo":"20061106074532.10376.60478.stgit@localhost","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2006-11-07T09:53:31Z","receivedAt":"2006-11-07T09:53:31Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Karl,\n\nOn 06/11/06, Karl Hasselström <kha@treskal.com> wrote:\n> This is required by some mail servers that want to change the transfer\n> encoding of the mail.\n\nThanks for digging into this problem and thanks to everyone else\n(especially Linus) for the detailed explanations.\n\nI'll include these patches (maybe modified) and I'll try to fix\n\"import\" as well.\n\n-- \n"},{"id":"295736","messageId":"b0943d9e0611071109w584f4f7fv3ba1b7dbd9413717@mail.gmail.com","threadId":"43588","inReplyTo":"b0943d9e0611070153s2a52f65k6ed4643e60a144b3@mail.gmail.com","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2006-11-07T19:09:06Z","receivedAt":"2006-11-07T19:09:06Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 07/11/06, Catalin Marinas <catalin.marinas@gmail.com> wrote:\n> I'll include these patches (maybe modified) and I'll try to fix\n> \"import\" as well.\n\nI re-implemented parts of the mail and import commands (inspiring from\nyour patches). They now use the email Python package. The mail command\nencodes the body to 7 or 8bit depending on non-ascii characters. The\nheaders are QP-encoded. The import command can decode messages\nproperly and can also handle multipart e-mails.\n\nI still have to write a test script but my simple tests showed that it\nworks. Please let me know if there is anything wrong (especially with\nthe QP-encoding of the mail headers).\n\nThanks.\n\n-- \n"},{"id":"296845","messageId":"20061108084038.GA3164@diana.vm.bytemark.co.uk","threadId":"43588","inReplyTo":"b0943d9e0611071109w584f4f7fv3ba1b7dbd9413717@mail.gmail.com","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-08T08:40:38Z","receivedAt":"2006-11-08T08:40:38Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-11-07 19:09:06 +0000, Catalin Marinas wrote:\n\n> I re-implemented parts of the mail and import commands (inspiring\n> from your patches). They now use the email Python package. The mail\n> command encodes the body to 7 or 8bit depending on non-ascii\n> characters.\n\nEven though it turned out to be possible to use 8bit always?\n\n> The headers are QP-encoded.\n\nStrictly speaking, it's rfc2047-encoded. I think the options are QP\nand base64.\n\n> The import command can decode messages properly and can also handle\n> multipart e-mails.\n\nGoodie.\n\n> I still have to write a test script but my simple tests showed that\n> it works. Please let me know if there is anything wrong (especially\n> with the QP-encoding of the mail headers).\n\nI won't have time to check this out today (in fact, it may have to\nwait until the weekend). But when I do check it out, I might have time\nto write that test, so please holler if you start working on that.\n\n-- \nKarl Hasselström, kha@treskal.com\n"},{"id":"298692","messageId":"b0943d9e0611080141y3751039v37b0289147237e4f@mail.gmail.com","threadId":"43588","inReplyTo":"20061108084038.GA3164@diana.vm.bytemark.co.uk","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2006-11-08T09:41:33Z","receivedAt":"2006-11-08T09:41:33Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 08/11/06, Karl Hasselström <kha@treskal.com> wrote:\n> On 2006-11-07 19:09:06 +0000, Catalin Marinas wrote:\n>\n> > I re-implemented parts of the mail and import commands (inspiring\n> > from your patches). They now use the email Python package. The mail\n> > command encodes the body to 7 or 8bit depending on non-ascii\n> > characters.\n>\n> Even though it turned out to be possible to use 8bit always?\n\nI just let the Python email package to the encoding and it first tries\npure ascii and switches to 8bit if this fails. This package\nautomatically adds the proper e-mail headers based on the encoding\ntype. It can also do QP or base64 encodings (if someone complains of\nan old SMTP server, maybe I'll add a config option to force QP body).\n\n> > I still have to write a test script but my simple tests showed that\n> > it works. Please let me know if there is anything wrong (especially\n> > with the QP-encoding of the mail headers).\n>\n> I won't have time to check this out today (in fact, it may have to\n> wait until the weekend). But when I do check it out, I might have time\n> to write that test, so please holler if you start working on that.\n\nIt would be great if you can run a test script. I've been thinking\nmore of an \"import\" test that also checks both the \"export\" and \"mail\"\ncommands. BTW, I'll try to add support for mbox importing which is\npretty easy with the email package.\n\n-- \n"},{"id":"296087","messageId":"20061108100103.GA18117@diana.vm.bytemark.co.uk","threadId":"43588","inReplyTo":"b0943d9e0611080141y3751039v37b0289147237e4f@mail.gmail.com","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-08T10:01:03Z","receivedAt":"2006-11-08T10:01:03Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-11-08 09:41:33 +0000, Catalin Marinas wrote:\n\n> On 08/11/06, Karl Hasselström <kha@treskal.com> wrote:\n>\n> > On 2006-11-07 19:09:06 +0000, Catalin Marinas wrote:\n> >\n> > > I re-implemented parts of the mail and import commands\n> > > (inspiring from your patches). They now use the email Python\n> > > package. The mail command encodes the body to 7 or 8bit\n> > > depending on non-ascii characters.\n> >\n> > Even though it turned out to be possible to use 8bit always?\n>\n> I just let the Python email package to the encoding and it first\n> tries pure ascii and switches to 8bit if this fails.\n\nAh, OK, I misread you. This is precisely what I wanted.\n\n> It can also do QP or base64 encodings (if someone complains of an\n> old SMTP server, maybe I'll add a config option to force QP body).\n\nYes, but let's hope we don't have to. :-) And if we do have to, we\nshould probably autodetect it from the SMTP dialog as Linus explained\n(or rather, we should hope that the library can do this for us).\n\n> > > I still have to write a test script but my simple tests showed\n> > > that it works. Please let me know if there is anything wrong\n> > > (especially with the QP-encoding of the mail headers).\n> >\n> > I won't have time to check this out today (in fact, it may have to\n> > wait until the weekend). But when I do check it out, I might have\n> > time to write that test, so please holler if you start working on\n> > that.\n>\n> It would be great if you can run a test script. I've been thinking\n> more of an \"import\" test that also checks both the \"export\" and \"mail\"\n> commands.\n\nI was thinking along these lines too; first make sure the importer\nworks, by feeding it a number of hard-coded patches in different\nformats, and then make sure that the importer can read what the\nexporter produces. (With \"exporter\" meaning both \"stg export\" and \"stg\nmail\".)\n\nI didn't originally plan to thest the actual e-mail sending, but now\nthat I think of it, a simple script listening on a random port,\npretending to be an SMTP daemon, should be quite simple to set up.\n\n> BTW, I'll try to add support for mbox importing which is pretty easy\n> with the email package.\n\nSounds good. If you do it in time, I'll write a test for that too. ;-)\n\n-- \nKarl Hasselström, kha@treskal.com\n"},{"id":"298731","messageId":"20061111122403.GC11224@diana.vm.bytemark.co.uk","threadId":"43588","inReplyTo":"b0943d9e0611071109w584f4f7fv3ba1b7dbd9413717@mail.gmail.com","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-11T12:24:03Z","receivedAt":"2006-11-11T12:24:03Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-11-07 19:09:06 +0000, Catalin Marinas wrote:\n\n> I re-implemented parts of the mail and import commands (inspiring\n> from your patches). They now use the email Python package. The mail\n> command encodes the body to 7 or 8bit depending on non-ascii\n> characters. The headers are QP-encoded. The import command can\n> decode messages properly and can also handle multipart e-mails.\n>\n> I still have to write a test script but my simple tests showed that\n> it works. Please let me know if there is anything wrong (especially\n> with the QP-encoding of the mail headers).\n\nOne potentially hazardous thing: you encode the mail before letting\nthe user edit it (with the -e and -E switches). This means that the\nuser can insert non-ascii characters in the body after you've already\ndecided it's safe to use 7bit encoding. It also means that the user\nmust be careful to rfc2047-encode any changes to the Subject: and\nFrom: headers.\n\n-- \nKarl Hasselström, kha@treskal.com\n"},{"id":"298553","messageId":"b0943d9e0611160924s55383480x68832ef0a6183780@mail.gmail.com","threadId":"43588","inReplyTo":"20061111122403.GC11224@diana.vm.bytemark.co.uk","subject":"Re: [PATCH] Add a MIME-Version header to e-mails","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2006-11-16T17:24:01Z","receivedAt":"2006-11-16T17:24:01Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 11/11/06, Karl Hasselström <kha@treskal.com> wrote:\n> One potentially hazardous thing: you encode the mail before letting\n> the user edit it (with the -e and -E switches). This means that the\n> user can insert non-ascii characters in the body after you've already\n> decided it's safe to use 7bit encoding. It also means that the user\n> must be careful to rfc2047-encode any changes to the Subject: and\n> From: headers.\n\nI changed this to edit the mail before encoding it. You can no longer\nsee the full headers (those added by StGIT) but even in a normal\ne-mail client you can only see the whole headers after sending it (and\nif you receive it back).\n\n-- \n"}]}