python-arf
v0.0.3
Published
Node.js wrapper around the Python package arf, which is a processor for Abuse Reporting Format (ARF) messages.
Downloads
26
Readme
python-arf
Node.js wrapper around the Python package arf, which is a processor for Abuse Reporting Format (ARF) messages.
Table of Contents
Requirements
Ensure that you have a Python version of >= 3.5 installed (we do not support older versions of Python anymore across the entire organization):
python3 --version
Install the package arf:
pip3 install arf-mime
Install
npm:
npm install python-arf
yarn:
yarn add python-arf
Usage
Note that the source
is an ARF message and can be a file path (String), String, or Buffer.
const arf = require('python-arf');
// then/catch usage
arf(source)
.then(console.log)
.catch(console.error);
// async/await usage
(async () => {
try {
const result = await arf(source);
console.log(result);
} catch (err) {
console.error(err);
}
})();
Note that result
is an Object that looks like this:
{
MessageHeaders: {
Received: [
'from example.com (example.com [10.0.1.11]) by example.net with ESMTP id O63d4137594e46; Thu, 08 Mar 2005 16:00:00 -0400',
'from mailserver.example.net (mailserver.example.net [192.0.2.1]) by example.com with ESMTP id M63d4137594e46; Thu, 08 Mar 2005 14:00:00 -0400'
],
From: '<[email protected]>',
Date: 'Thu, 8 Mar 2005 17:40:36 EDT',
Subject: 'FW: Earn money',
To: '<[email protected]>',
MimeVersion: '1.0',
ContentType: 'multipart/report; report-type=feedback-report; boundary="part1_13d.2e68ed54_boundary"'
},
OriginalMessageHeaders: {
From: '<[email protected]>',
Received: 'from mailserver.example.net (mailserver.example.net [192.0.2.1]) by example.com with ESMTP id M63d4137594e46; Thu, 08 Mar 2005 14:00:00 -0400',
To: '<Undisclosed Recipients>',
Subject: 'Earn money',
MimeVersion: '1.0',
ContentType: 'text/plain',
MessageId: '[email protected]',
Date: 'Thu, 02 Sep 2004 12:31:03 -0500'
},
FeedbackReport: {
FeedbackType: 'abuse',
UserAgent: 'SomeGenerator/1.0',
Version: '1',
OriginalMailFrom: '<[email protected]>',
OriginalRcptTo: '<[email protected]>',
ArrivalDate: 'Thu, 8 Mar 2005 14:00:00 EDT',
ReportingMta: 'dns; mail.example.com',
SourceIp: '192.0.2.1',
AuthenticationResults: 'mail.example.com; spf=fail [email protected]',
ReportedDomain: 'example.net',
ReportedUri: [ 'http://example.net/earn_money.html', 'mailto:[email protected]' ],
RemovalRecipient: '[email protected]'
},
OriginalMessagePayload: 'From: <[email protected]>\n' +
'Received: from mailserver.example.net (mailserver.example.net\n' +
'\t[192.0.2.1]) by example.com with ESMTP id M63d4137594e46;\n' +
'\tThu, 08 Mar 2005 14:00:00 -0400\n' +
'To: <Undisclosed Recipients>\n' +
'Subject: Earn money\n' +
'MIME-Version: 1.0\n' +
'Content-type: text/plain\n' +
'Message-ID: [email protected]\n' +
'Date: Thu, 02 Sep 2004 12:31:03 -0500\n' +
'\n' +
'Spam Spam Spam\n' +
'Spam Spam Spam\n' +
'Spam Spam Spam\n' +
'Spam Spam Spam'
}
Therefore if you wanted to access the original message payload in the ARF report (which is what we needed to do in Forward Email, then you'd retrieve it via result.OriginalMessagePayload
.
Contributors
| Name | Website | | -------------- | -------------------------- | | Nick Baugh | http://niftylettuce.com/ |