<commit_before>#!/usr/bin/env node
'use strict';

var smtp = require('simplesmtp');
var util = require('util');
var MailParser = require('mailparser').MailParser;
var mailparser = new MailParser();

process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (text) {
  console.log('received data:', util.inspect(text));
  mailparser.write(text);
});

process.stdin.on('end', function() {
	mailparser.end();
});

mailparser.on('end', function(mail){
	console.log('created the mail envelope:');

	// object structure for parsed e-mail
	console.log(mail);

	var smtpClient = smtp.connect(25, 'localhost');
	smtpClient.once('idle', function() {
	    smtpClient.useEnvelope(mail.headers);
	});

	smtpClient.on("message", function(){
		smtpClient.write(mail.text);
		smtpClient.end();<commit_msg>breaking out hard-coded smtp settings to a configuration object<commit_after>#!/usr/bin/env node
'use strict';

var smtp = require('simplesmtp');
var util = require('util');
var MailParser = require('mailparser').MailParser;
var mailparser = new MailParser();

var config = {
	smtp: {
		host: 'localhost',
		port: 25
	}
};

process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (text) {
  console.log('received data:', util.inspect(text));
  mailparser.write(text);
});

process.stdin.on('end', function() {
	mailparser.end();
});

mailparser.on('end', function(mail){
	console.log('created the mail envelope:');

	// object structure for parsed e-mail
	console.log(mail);

	var smtpClient = smtp.connect(config.smtp.port, config.smtp.host);
	smtpClient.once('idle', function() {
	    smtpClient.useEnvelope(mail.headers);
	});

	smtpClient.on("message", function(){
		smtpClient.write(mail.text);
		smtpClient.end();
{'fraction_non_alphanumeric': 0.17901234567901234, 'fraction_numerical': 0.003367003367003367, 'mean_word_length': 5.436823104693141, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5761649', 'n_tokens_mistral': 631, 'n_tokens_neox': 601, 'n_words': 118}