gene1wood / birch-girder

An Email Interface for GitHub Issues
GNU General Public License v3.0
9 stars 3 forks source link

Text only emails aren't being parsed correctly #39

Open gene1wood opened 4 years ago

gene1wood commented 4 years ago

The new parsing from #37 doesn't appear to handle cases like this correctly (where there is only text and no html)

Return-Path: <asender@example.com>
Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198])
 by inbound-smtp.us-west-2.amazonaws.com with SMTP id 1tm326djlseptkjh3eieao3ici2sp94c6in3q0o1
 for birch-girder-recipient@tickets.example.com;
 Fri, 20 Nov 2020 23:00:58 +0000 (UTC)
X-SES-Spam-Verdict: PASS
X-SES-Virus-Verdict: PASS
Received-SPF: pass (spfCheck: domain of example.com designates 217.70.183.198 as permitted sender) client-ip=217.70.183.198; envelope-from=asender@example.com; helo=relay6-d.mail.gandi.net;
Authentication-Results: amazonses.com;
 spf=pass (spfCheck: domain of example.com designates 217.70.183.198 as permitted sender) client-ip=217.70.183.198; envelope-from=asender@example.com; helo=relay6-d.mail.gandi.net;
 dmarc=none header.from=example.com;
X-SES-RECEIPT: AEFBQUFBQUFBQUFGVjluZ2Jaa3NjbHdlcHFJY0dGUGJVOWpML1JWbVFXWG1PT2p3U1VOS25aNjhKSm9KVWNJTzBCY3pwaHpPTXZzU2Z5ODlhUjg4bjBOUDF6Zzk0bFFrRUhHaXFOMUtKVmRhNWx6ZHJTK3Q1ODdYblBJMXM1blBSaG5lNXA4UlU2QWlWTUdoQVBBV3RJVjJqOS96OVQ1WGdhTE9UZ1l4Wk8zTUp1dVBzTlRxeS9Eb1BhVjRhTzRCMmZsTCsrdUdWQk1IRUxxMElvRzVZWDlCYlFFbm94dEZyS1NPdVhacUpoendaTi9IbUFXQnpaNGVVNVNJd2RBcUNWMGpCTmErWWcxSC9Ma2ZEVE9lOHZKU0VpTDVjaGZsM2dJeWViT3c0ZUVnWXUrRXFiSENsZ0E9PQ==
X-SES-DKIM-SIGNATURE: a=rsa-sha256; q=dns/txt; b=hCUEGu/wunn5ImzS1hEx77Z+zK1T3wh/+DnymwOA/TOmw0h3RLpHFAUENvIYl80ARt/wFu/aW5/+r6ZLQNEMUMpJ3vD3u/NVlJHOUlC4o3RafhnhvBPcJQFi5g9iU/WpwyxZ06eVlBVtC+OTHremDhJW5Zqo7gexBVVKdYnYJaY=; c=relaxed/simple; s=hsbnp7p3ensaochzwyq5wwmceodymuwv; d=amazonses.com; t=1605913259; v=1; bh=18oVmd3MQ1gGsvYAtPtujFcOzdcNoQVYUP8JadKw/ao=; h=From:To:Cc:Bcc:Subject:Date:Message-ID:MIME-Version:Content-Type:X-SES-RECEIPT;
Received: from spool.mail.gandi.net (spool5.mail.gandi.net [217.70.178.214])
    by relay6-d.mail.gandi.net (Postfix) with ESMTP id 30190C000B
    for <birch-girder-recipient@tickets.example.com>; Fri, 20 Nov 2020 23:00:56 +0000 (UTC)
Received: from srv1.msp.example.com (srv1.msp.example.com [204.246.122.3])
    by spool.mail.gandi.net (Postfix) with ESMTPS id 53263D80F7C
    for <birch-girder-recipient@example.com>; Fri, 20 Nov 2020 23:00:55 +0000 (UTC)
Received: by srv1.msp.example.com (Postfix, from userid 33)
    id 27D8BC0E83; Fri, 20 Nov 2020 23:00:54 +0000 (UTC)
To: birch-girder-recipient@example.com
Subject: This is my subject
X-PHP-Originating-Script: 1002:class-phpmailer.php
Date: Fri, 20 Nov 2020 23:00:54 +0000
From: Some Name <noreply@example.com>
Reply-To: jdoe@example.com
Message-ID: <9f2f864bc5a590b2fc36671727c5fd6a@example.com>
X-Mailer: PHPMailer 5.2.27 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="b1_9f2f864bc5a590b2fc36671727c5fd6a"
Content-Transfer-Encoding: 8bit
X-GND-Status: LEGIT
Received-SPF: pass (spool5: domain of example.com designates 204.246.122.3 as permitted sender) client-ip=204.246.122.3; envelope-from=asender@example.com; helo=srv1.msp.example.com;

This is a multi-part message in MIME format.

--b1_9f2f864bc5a590b2fc36671727c5fd6a
Content-Type: text/plain; charset=us-ascii

Text body payload goes here
text text text

--b1_9f2f864bc5a590b2fc36671727c5fd6a
Content-Type: application/octet-stream; name="id-rsa.pub"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=id-rsa.pub

c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFDQVFEZEJWV3RtWTR1aEtPaGxNdVVY
REDACTED
Cg==

--b1_9f2f864bc5a590b2fc36671727c5fd6a--
gene1wood commented 3 years ago

It also doesn't work with non-mime based text emails like this

Return-Path: <mailfrom-sender@example.com>
Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232])
 by inbound-smtp.us-west-2.amazonaws.com with SMTP id t0vgoot1robqagi0vffiahkdlp7ga86bseqic601
 for support@tickets.example.com;
 Mon, 28 Dec 2020 16:13:26 +0000 (UTC)
X-SES-Spam-Verdict: PASS
X-SES-Virus-Verdict: PASS
Received-SPF: pass (spfCheck: domain of example.com designates 217.70.178.232 as permitted sender) client-ip=217.70.178.232; envelope-from=mailfrom-sender@example.com; helo=relay12.mail.gandi.net;
Authentication-Results: amazonses.com;
 spf=pass (spfCheck: domain of example.com designates 217.70.178.232 as permitted sender) client-ip=217.70.178.232; envelope-from=mailfrom-sender@example.com; helo=relay12.mail.gandi.net;
 dmarc=none header.from=example.com;
X-SES-RECEIPT: AEFBQUFBQUFBQUFGZjRJSzBSbjY3aS93MkpkdCt3U0tYK0JNY1pjUzJpTDBSOTZ3a3o1dUVHVVdzOWdrbVRMbXNxTDhQcG5FbjFLV1M5YWlYZ1c5ZkczMjBrUGFlQU9nejFscWFjUXFsTGFxblUwU1FSOWpZYzBwUnJlU2VjNWxpaVJFVktZWWRxeTZIZDhCMUsreUUrTzNqaUk1eVRUZXQwNUxrbmxCdW1IeXhLL0F2b2xKZi9ZU3JrQ1BFMGU3dnozVFNKNVRSMXlDYVducXg2ckVXaVh1KzRuQU9DQnh0YTBQdlZNSmtwMU0wMUlqY1gvcDBCN041anVpL1E0RDVUdm1GM01PQnRWRmxDSXgwQzZvYlJ2MmM0aFJFbnl3RmNJMnc4WXlaOHl1aGs1a0pXbU11c1E9PQ==
X-SES-DKIM-SIGNATURE: a=rsa-sha256; q=dns/txt; b=FWh/VIAY+j8as5y3Dr7w++BevAppOsKkgIxkLkpwJ84kD/VVsn9p4ROrZkZ67e5sc71nwyRSVErvs85jmyEi3ca13IFITTX5vTjo4xPM7V5aX/08IXhRe7nHG0jotWH21b5s/aR90glWDKtHTJdIOVajTQ11IINCU04D6u0Oc9k=; c=relaxed/simple; s=hsbnp7p3ensaochzwyq5wwmceodymuwv; d=amazonses.com; t=1609172008; v=1; bh=/AUZkCgEqnJuCDZfukfatYPN2oAZlaDITyuqlGyYEqU=; h=From:To:Cc:Bcc:Subject:Date:Message-ID:MIME-Version:Content-Type:X-SES-RECEIPT;
Received: from spool.mail.gandi.net (spool4.mail.gandi.net [217.70.178.213])
    by relay12.mail.gandi.net (Postfix) with ESMTPS id BA8E1200002
    for <support@tickets.example.com>; Mon, 28 Dec 2020 16:13:24 +0000 (UTC)
Received: from srv1.msp.iocoop.org (srv1.msp.iocoop.org [204.246.122.3])
    by spool.mail.gandi.net (Postfix) with ESMTPS id AA9C37804A5
    for <support@example.com>; Mon, 28 Dec 2020 16:13:23 +0000 (UTC)
Received: by srv1.msp.iocoop.org (Postfix, from userid 33)
    id B192BC424B; Mon, 28 Dec 2020 16:13:21 +0000 (UTC)
To: support@example.com
Subject: Here i my subject
X-PHP-Originating-Script: 1002:PHPMailer.php
Date: Mon, 28 Dec 2020 16:13:21 +0000
From: A senders name <noreply@example.com>
Reply-To: some-other-senderd@example.com
Message-ID: <zut8FDmAOvNVgFwEgNUqtTJJpP3s5tSGzjXgChSo@iocoop.org>
X-Mailer: PHPMailer 6.2.0 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-GND-Status: LEGIT
Received-SPF: pass (spool4: domain of example.com designates 204.246.122.3 as permitted sender) client-ip=204.246.122.3; envelope-from=mailfrom-sender@example.com; helo=srv1.msp.iocoop.org;

Body of email goes here