EmailAnonymiser
EmailAnonymiser parses mime encoded email messages and anonymises them for use without containing sensitive information.
Installation
npm install email-anonymiser
Usage
Require EmailAnonymiser module
var EmailAnonymiser = require('email-anonymiser');
Anonymise a directory of email files
EmailAnonymiser.anonymise('dir/to/emails');
anonymise returns a promise containing an array of anonymised emails.
Example
var EmailAnonymiser = require('email-anonymiser');
EmailAnonymiser.anonymise(emailDir, reportProgress).then(function(emails) {
console.log(emails);
}, function(err) {
console.error(err);
});
function reportProgress(processed, total) {
console.log(processed + ' out of ' + total);
}
Anonymisation Steps
1. Filter properties
Makes a copy of the email with only the following fields:
- messageId
- subject
- date
- text
2. Tidies up text
Removes newlines, character returns, tabs and double spaces from the email body text.
3. Removes links
Removes all links from the email body which start with:
- http:
- https:
- file:
- mailto:
4. Removes email addresses
Removes all references to email addresses in the email body text.
5. Removes embedded content links
Removes all links to embedded content, such as when the user has inserted an inline image, document, etc...
6. Removes email signature
Guesses where and removes an email signature from the email body text.
7. Removes names
Uses a list of over 8800 names to remove references from the email body text.
8. Removes UK phone numbers
Removes UK phone numbers which start with and without the country prefix.
9. Removes UK National Insurance Numbers
Removes UK National Insurance Numbers from the email body text.
10. Removes bank account sort code and numbers
Removes bank account sort code and numbers in the email body.
Sample Email
Original email
From: Sender Name <sender@email-anonymiser.com>
To: Receiver Name <receiver@email-anonymiser.com>
Subject: Sample email
Message-ID: <1234567890@email-anonymiser>
Date: Thu, 22 Jul 2016 12:32:11 +0000
Hello, my name is James.
My email address is james.mcavoy@mail.com. You can also reach me on
<mailto:j.mcavoy@some-other-domain.com>.
I'm having trouble with my bank account 12-34-56 12345678 and not getting paid.
Here's a copy of my last bank statement [cid:27843783478349.jpg]
As you can see from my bank's http://www.mybank.com/faqs web site, they say to
contact you. They also have charged me a fee for your error which you can see
at https://www.mybank.com/charges
My bank account manager is David. He said to give you my NI number, which is
NS123456A if that helps.
If you need to contact me further by mobile number is 07712 345678 and my home
number is 01234 567 890. If you need to contact me from abroad you can call
+44 1234 567 890.
Kind regards,
Sender2 Name 2
Anonymised email
{
"messageId": "1234567890@email-anonymiser",
"subject": "Sample email",
"date": "Thu, 22 Jul 2016 12:32:11 +0000",
"text": "Hello, my name is My email address is . You can also reach me on . I'm having trouble with my bank account and not getting paid. Here's a copy of my last bank statement As you can see from my bank's web site, they say to contact you. They also have charged me a fee for your error which you can see at My bank account manager is He said to give you my NI number, which is if that helps. If you need to contain me further by mobile number is and my home number is . If you need to contact me from abroad you can call ."
}
License
ISC