Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 1594455689612692529@xxx Fri Mar 09 10:30:39 +0000 2018
- X-GM-THRID: 1594455689612692529
- Message-ID: <0620b50c-1f22-4513-b595-7b64c9632c67@abc-mail.com>
- X-Mailgun-Track-Clicks: no
- From: "Dennis" <notifications@abc-mail.com>
- X-Mailgun-Track-Opens: no
- function extractNames(text) {
- return text.match(/(From: [^>]* <notifications@abc-mail.com>)/gi);
- }
- //body
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w
- 3.org/TR/REC-html40/loose.dtd">=0A<html>=0A ..etc
- ... there is too much text and here is the email of the user
- padding: 0"><a href=3D"mailto:dennis.bra@marketics.com" st=
- yle=3D"color: default; text-decoration: underline">dennis.brahg@marketics.com</a></td>=0A<td style=3D"
- ... there is could be 1 email but also could be 2 or 3 of them
- padding: 0"><a href=3D"dennis.bra@gmail.com" st=
- yle=3D"color: default; text-decoration: underline">dennis.bra@gmail.com</a></td>=0A<td style=3D"
- function extractEmails (text) {
- let txt = text.replace(/=/gi, "");
- txt = txt.replace(/r?n|r/g, "");
- txt = txt.replace(/( )/g, "");
- return txt.match(/(font-weight:normal;padding:0"><ahref3D"mailto:[sS]*?"style3D"color:default;text-decoration:underline">)/gi);
- }
- fs.readFile('MESSAGES.txt', function (err, data) {
- if (err) return console.error(err);
- EMAILS = extractEmails(data.toString());
- NAMES = extractNames(data.toString());
- }
- EMAILS = EMAILS.map(item => {
- item = item.replace(/font-weight:normal;padding:0"><ahref3D"mailto:/gi, '');
- item = item.replace(/"style3D"color:default;text-decoration:underline">/gi, '');
- return item ? item : 'NO EMAIL PROVIDED';
- });
- NAMES = NAMES.map(item => {
- item = item.replace(/notifications@intercom-mail.com>/gi, '');
- return item.replace(/^From: /gi, '').replace(/["<]/gi, '');
- });
- let SUM = [];
- for (let i = 0; i < EMAILS.length; i++) {
- SUM.push(`${NAMES[i]} ${EMAILS[i]} rn`);
- }
- fs.writeFile('SUM.txt', SUM, function(err) {
- if (err) return console.error(err);
- console.log("SUM written successfully!");
- });
Add Comment
Please, Sign In to add comment