def test_exim3(self): header = "from 254.253.2.109.rev.sfr.net ([109.2.253.254])\tby\n grb212uploads.mooo.com with smtp (Exim 4.82)\t(envelope-from\n <*****@*****.**>)\tid 1XxTav-0002JM-P9\tfor [email protected]; Sun,\n 07 Dec 2014 04:37:18 +0000" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '109.2.253.254') self.assertEqual(data['from_name'], None) self.assertEqual(data['from_hostname'], '254.253.2.109.rev.sfr.net') self.assertEqual(data['by_hostname'], 'grb212uploads.mooo.com')
def test_postfix15(self): header = "from [10.0.1.11] ([1.2.3.4]) by\n\tp3plsmtp.example.com with id 4KyS1p00T4yQ7hw01KyTCQ;\n\tFri, 17 Oct 2014 12:58:31 -0700" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '[10.0.1.11]') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'p3plsmtp.example.com') self.assertEqual(data['server'], 'postfix')
def test_postfix14(self): header = "from servername (server.example.org [1.2.3.4] (may be\n\tforged)) by server2.example.com with ESMTP id 1qv2xty0hs-7082 for\n\t<*****@*****.**>; Fri, 09 Jan 2015 11:40:33 +0000" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'servername') self.assertEqual(data['from_hostname'], 'server.example.org') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'server2.example.com')
def test_postfix10(self): header = "from MacBook-di-Alessandro.local (unknown [192.168.1.211])\t(using\n TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))\t(No client\n certificate requested)\tby mail.example.org (Postfix) with ESMTPSA id\n CB7764440B4C;\tWed, 3 Jun 2015 17:38:29 +0200 (CEST)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'MacBook-di-Alessandro.local') self.assertEqual(data['from_hostname'], 'unknown') self.assertEqual(data['from_ip'], '192.168.1.211') self.assertEqual(data['by_hostname'], 'mail.example.org')
def test_exim4(self): header = "from [1.2.3.4] (port=52853 helo=[192.168.1.100]) by\n\tgator4129.hostgator.com with esmtpsa (UNKNOWN:DHE-RSA-AES256-GCM-SHA384:256)\n\t(Exim 4.82) (envelope-from <*****@*****.**>) id 1Yaixf-0004rk-UE for\n\[email protected]; Wed, 25 Mar 2015 05:55:00 -0500" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_name'], '[192.168.1.100]') self.assertEqual(data['by_hostname'], 'gator4129.hostgator.com') self.assertEqual(data['server'], 'exim')
def test_oracle2(self): header = "from [172.20.10.2] (222.example.com [1.2.3.4]) by\n\tnk11p04mm-asmtp001.mac.com (Oracle Communications Messaging Server\n\t7u4-27.10(7.0.4.27.9) 64bit (built Jun 6 2014)) with ESMTPSA id\n\t<*****@*****.**>; Fri, 22 Aug 2014 01:52:13\n\t +0000 (GMT)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '[172.20.10.2]') self.assertEqual(data['from_hostname'], '222.example.com') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'nk11p04mm-asmtp001.mac.com')
def test_postfix8(self): header = "from mail.user.it (mail.user.it [10.2.2.2]) by\n manta.example.org with ESMTP id zd3xinp0NwYvANyH for\n <*****@*****.**>; Fri, 05 Jun 2015 18:47:29 +0200 (CEST)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'mail.user.it') self.assertEqual(data['from_hostname'], 'mail.user.it') self.assertEqual(data['from_ip'], '10.2.2.2') self.assertEqual(data['by_hostname'], 'manta.example.org')
def test_squirrelmail(self): header = "from 1.2.3.4 (SquirrelMail authenticated user\n\t [email protected]) by webmail.example.org with HTTP; Thu, 27\n Feb 2014 14:41:31 +0100 (CET)" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'webmail.example.org') self.assertEqual(data['envelope_from'], '*****@*****.**') self.assertEqual(data['server'], 'SquirrelMail')
def test_unknown4(self): header = "from unknown (HELO ?10.4.3.2?)\n\t([email protected]@1.2.3.4_trustedrelay) by 192.168.0.240 with\n\tESMTPA; 9 Sep 2013 09:10:33 -0000" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '?10.4.3.2?') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_hostname'], 'unknown') self.assertEqual(data['by_hostname'], '192.168.0.240')
def test_oracle1(self): header = "from imac.home ([1.2.3.4]) by vms173023.example.net\n (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014))\n with ESMTPA id <*****@*****.**>; Sat, 23 May 2015\n 12:18:52 -0500 (CDT)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'imac.home') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'vms173023.example.net') self.assertEqual(data['id'], '*****@*****.**')
def test_exchange8(self): header = "from (1.2.3.4) by exchange.example.org (192.168.100.80) with\n\tMicrosoft SMTP Server id 14.3.195.1; Wed, 15 Oct 2014 11:18:39 +0200" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'exchange.example.org') self.assertEqual(data['by_ip'], '192.168.100.80')
def test_unknown5(self): header = "from [1.2.3.4] ([1.2.3.4]) by\n\tserver.example.org ([4.5.6.7]) with SMTP; Sun, 19 Oct 2014\n\t02:55:55 GMT" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '[1.2.3.4]') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'server.example.org') self.assertEqual(data['by_ip'], '4.5.6.7')
def test_exchange5(self): header = "from 486006-USEXCH02.CMP.LOCAL ([fe80::250:56ff:fe85:5095%11]) by\n\t486006-USEXCH02.CMP.LOCAL ([fe80::250:56ff:fe85:5095%11]) with Microsoft SMTP\n\tServer id 14.03.0123.003; Tue, 24 Jun 2014 10:16:07 -0500" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '486006-USEXCH02.CMP.LOCAL') self.assertEqual(data['from_ip'], 'fe80::250:56ff:fe85:5095') self.assertEqual(data['by_hostname'], '486006-USEXCH02.CMP.LOCAL') self.assertEqual(data['by_ip'], 'fe80::250:56ff:fe85:5095')
def test_exchange4(self): header = "from EUR03-VE1-obe.outbound.protection.outlook.com ([65.54.190.201]) by BAY004-OMC4S3.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008);\n\tMon, 5 Dec 2016 04:36:38 -0800" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'EUR03-VE1-obe.outbound.protection.outlook.com') self.assertEqual(data['from_ip'], '65.54.190.201') self.assertEqual(data['by_hostname'], 'BAY004-OMC4S3.hotmail.com')
def test_postfix9(self): header = "from mail.lab.it ([127.0.0.1])\tby localhost (mail.lab.it\n [127.0.0.1]) (server, port 10024)\twith ESMTP id Czb9AlcNsGzC; Fri, 5\n Jun 2015 18:47:27 +0200 (CEST)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'mail.lab.it') self.assertEqual(data['from_hostname'], '') self.assertEqual(data['from_ip'], '127.0.0.1') self.assertEqual(data['by_hostname'], 'localhost')
def test_nemesis(self): header = "from [192.168.1.132] ([1.2.3.4]) by mail.server.example.org\n\t(server1) with ESMTPA (Nemesis) id 0M9GoA-1Yx9783qd4-00ChEw for\n\t<*****@*****.**>; Wed, 06 May 2015 17:15:53 +0200" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_name'], '[192.168.1.132]') self.assertEqual(data['by_hostname'], 'mail.server.example.org') self.assertEqual(data['envelope_for'], '*****@*****.**')
def test_ecelerity5(self): header = "from [1.2.3.4] ([[1.2.3.4:12140]) by\n\thosting.example.org (envelope-from\n\t<*****@*****.**>) (ecelerity 2.2.2.45 r(34222M))\n\twith ECSTREAM id xS/71-64990-83274771; Fri, 07 Nov 2014 12:03:25 +0100" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_hostname'], '[1.2.3.4]') self.assertEqual(data['by_hostname'], 'hosting.example.org') self.assertEqual(data['server'], 'ecelerity')
def test_ecelerity4(self): header = "from [1.2.3.4] ([1.2.3.4:11527] helo=localhost.localdomain) by\n\treturnpath.example.org (envelope-from\n\t<bounce-use=M=28052037815=echo4=ABAD51E2652A00D5A4C7882624EFBC5B@returnpath.example.com>)\n\t(ecelerity 3.5.3.37097 r(Platform:3.5.3.0)) with ESMTP id\n\t52/34-40305-20E54345; Tue, 07 Oct 2014 14:41:22 -0700" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_hostname'], '[1.2.3.4]') self.assertEqual(data['from_name'], 'localhost.localdomain') self.assertEqual(data['by_hostname'], 'returnpath.example.org')
def test_ecelerity1(self): header = "from [10.1.8.1] ([10.1.8.1:41412] helo=abmas01.marketo.org)\tby\n abmta03.marketo.org (envelope-from <*****@*****.**>)\t(ecelerity\n 3.6.4.44580 r(Platform:3.6.4.1)) with ESMTP\tid 43/97-60201-DE17D155; Thu, 02\n Apr 2015 11:44:29 -0500" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '10.1.8.1') self.assertEqual(data['from_hostname'], '[10.1.8.1]') self.assertEqual(data['from_name'], 'abmas01.marketo.org') self.assertEqual(data['by_hostname'], 'abmta03.marketo.org') self.assertEqual(data['protocol'], 'ESMTP')
def test_unknown2(self): header = "from fbx.proxad.net (HELO MACHINE)\n\t([email protected]@1.2.3.4) by ns0.ovh.net with SMTP; 2 Oct 2013\n\t16:46:22 +0200" data = ReceivedParser.parse(header) self.assertEqual(data['from_hostname'], 'fbx.proxad.net') self.assertEqual(data['from_name'], 'MACHINE') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'ns0.ovh.net') self.assertEqual(data['envelope_from'], '*****@*****.**')
def test_javasms2(self): header = "from [192.168.1.27] ([unknown] [1.2.3.4]) by vms173023.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id \n\t <*****@*****.**>; Thu, 03 Oct 2013 08:14:37 -0500\n\t(CDT)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], '[192.168.1.27]') self.assertEqual(data['from_hostname'], 'unknown') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'vms173023.mailsrvcs.net') self.assertEqual(data['server'], 'Sun Java System Messaging Server')
def test_javasms(self): header = "from imac-27.home ([unknown] [1.2.3.4]) by\n\tvms173019.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit\n\t(built Apr 16 2009)) with ESMTPA id\n\t<*****@*****.**>; Tue, 19 Aug 2014 10:22:07 -0500 (CDT)" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'imac-27.home') self.assertEqual(data['from_hostname'], 'unknown') self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['by_hostname'], 'vms173019.mailsrvcs.net') self.assertEqual(data['server'], 'Sun Java System Messaging Server')
def test_communigate3(self): header = "from 4.5.6.7 (account <*****@*****.**> HELO\n\texample.org) by example.com (CommuniGate Pro SMTP 5.2.3) with ESMTPA id\n\t 557936202 for <*****@*****.**>; Sat, 14 Sep 2013 19:19:52 +0700" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '4.5.6.7') self.assertEqual(data['from_name'], 'example.org') self.assertEqual(data['by_hostname'], 'example.com') self.assertEqual(data['envelope_from'], '*****@*****.**') self.assertEqual(data['server'], 'CommuniGate')
def test_assp1(self): header = "from server1 ([1.2.3.4] helo=server1) by\n\texample.org with ESMTP (ASSP 1.9.9); 14 Apr 2015 14:50:17 +0800" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_hostname'], 'server1') self.assertEqual(data['from_name'], 'server1') self.assertEqual(data['by_hostname'], 'example.org') self.assertEqual(data['protocol'], 'ESMTP')
def test_ecelerity2(self): header = "from [10.0.0.51] ([10.0.0.51:0996]\n helo=1234.example.org)\tby FDC7270 (envelope-from\n <*****@*****.**>)\t(ecelerity 3.5.1.37854 r(Momo-dev:3.5.1.0))\n with ESMTP\tid 9F/B3-489A4-1A4FB098; Mon, 23 Feb 2015 09:30:58 -0500" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '10.0.0.51') self.assertEqual(data['from_hostname'], '[10.0.0.51]') self.assertEqual(data['from_name'], '1234.example.org') self.assertEqual(data['by_hostname'], 'FDC7270') self.assertEqual(data['protocol'], 'ESMTP')
def test_ecelerity3(self): header = "from [10.220.136.203] ([10.220.136.203:60938] helo=na47-app2-11-dfw.ops.sfdc.net)\n\tby mx4-dfw-sp3.mta.salesforce.com (envelope-from <*****@*****.**>)\n\t(ecelerity 3.6.25.56547 r(Core:3.6.25.0)) with ESMTPS (cipher=ECDHE-RSA-AES256-GCM-SHA384) \n\tid BD/7B-10868-A85F2CA5; Tue, 03 Apr 2018 03:31:22 +0000" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '10.220.136.203') self.assertEqual(data['from_hostname'], '[10.220.136.203]') self.assertEqual(data['from_name'], 'na47-app2-11-dfw.ops.sfdc.net') self.assertEqual(data['by_hostname'], 'mx4-dfw-sp3.mta.salesforce.com') self.assertEqual(data['protocol'], 'ESMTPS')
def test_communigate1(self): header = "from [1.2.3.4] (account [email protected] HELO\n\tserver.example.com) by sender.example.org\n\t(CommuniGate Pro SMTP 5.2.3) with ESMTPA id 960713191 for\n\[email protected]; Mon, 14 Oct 2013 21:43:21 -0600" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_name'], 'server.example.com') self.assertEqual(data['by_hostname'], 'sender.example.org') self.assertEqual(data['envelope_from'], '*****@*****.**') self.assertEqual(data['server'], 'CommuniGate')
def test_communigate2(self): header = "from [4.5.6.7] (account [email protected] HELO\n\tserver.example.org) by (CommuniGate Pro SMTP 5.2.3) with ESMTPA id\n\t192459198 for [email protected]; Mon, 30 Sep 2013 15:12:33 +0700" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '4.5.6.7') self.assertEqual(data['from_name'], 'server.example.org') self.assertEqual(data['by_hostname'], '') self.assertEqual(data['envelope_from'], '*****@*****.**') self.assertEqual(data['server'], 'CommuniGate')
def test_nemesis2(self): header = "from [10.0.1.2] (server.fastwebnet.it [1.2.3.4]) by\n\trelay.server.example.org (node=server104) with ESMTP (Nemesis) id\n\t0LvAna-1WRMgI2ZYg-010POX; Wed, 23 Jul 2014 10:55:24 +0200" data = ReceivedParser.parse(header) self.assertEqual(data['from_ip'], '1.2.3.4') self.assertEqual(data['from_name'], '[10.0.1.2]') self.assertEqual(data['from_hostname'], 'server.fastwebnet.it') self.assertEqual(data['by_hostname'], 'relay.server.example.org') self.assertEqual(data['server'], 'nemesis')
def test_exim5(self): header = "from apache by example.com with local (Exim 4.67) (envelope-from\n\t<*****@*****.**>) id S3E9AW-L5D4OI-CH for <*****@*****.**>;\n\tWed, 28 May 2014 16:49:20 +1000" data = ReceivedParser.parse(header) self.assertEqual(data['from_name'], 'apache') self.assertEqual(data['by_hostname'], 'example.com') self.assertEqual(data['envelope_from'], '*****@*****.**') self.assertEqual(data['envelope_for'], '*****@*****.**') self.assertEqual(data['server'], 'exim')