<commit_before>'use strict';
var child_process = require('child_process');
var conf = require('./conf.js');
var constants = require('./constants.js');
var DNS = require('dns');
var nodemailer = require('node4mailer');
var fs = require('fs');

if (!(window && window.cordova)) {
	DNS.setServers(["8.8.8.8", "172.16.17.32"]); // google public DNS, China 114dns
}

function sendmail(params){
	var child = child_process.spawn('/usr/sbin/sendmail', ['-t', params.to]);
	child.stdout.pipe(process.stdout);
	child.stderr.pipe(process.stderr);
	child.stdin.write("Return-Path: <"+params.from+">\r\nTo: "+params.to+"\r\nFrom: "+params.from+"\r\nSubject: "+params.subject+"\r\n\r\n"+params.body);
	child.stdin.end();
}

function sendBugEmail(error_message, exception){
	sendmail({
		to: conf.bug_sink_email,
		from: conf.bugs_from_email,
		subject: 'BUG '+error_message.substr(0, 200).replace(/\s/g, ' '),
		body: error_message + "\n\n" + ((typeof exception === 'string') ? exception : JSON.stringify(exception, null, '\t'))
	});
}

function sendSMTPEmail(email, params, cb, forceInsecure) {
	var hostname = email.slice(email.indexOf("@")+1);
	var secure = forceInsecure ? false : true;
	DNS.resolveMx(hostname, function(err, exchanges){
		var exchange = hostname;
		if (exchanges && exchanges.length)
			exchange = exchanges[0].exchange;

		var transporter = nodemailer.createTransport({
			host: exchange,
			port: 25,
			secure: false,
			requireTLS: secure,
			tls: {
				rejectUnauthorized: secure
			}
		});

		fs.readFile(__dirname + '/email_template.html', 'utf8', function (err, template) {
			params.amount -= constants.TEXTCOIN_CLAIM_FEE;
			var html = template.replace(/\{\{mnemonic\}\}/g, params.mnemonic).replace(/\{\{amount\}\}/g, params.amount).replace(/\{\{asset\}\}/g, params.asset);
			var text = "Someone sent you " + params.amount + " " + params.asset + ", to claim it download Byteball wallet and recover Wallet from the following Seed: " + params.mnemonic;
			let mailOptions = {
				from: '"Byteball Wallet" <<EMAIL>>',
				to: email,
				subject: 'Byteball Transaction Received',
				text: text, // plain text body
				html: html // html body
			};

			transporter.sendMail(mailOptions, function(error, info) {
				if (error) {
					return cb(error);
				}
				console.log('Message sent: %s', info.messageId);
				cb(null, info);
			});
		});
	});<commit_msg>email subject<commit_after>'use strict';
var child_process = require('child_process');
var conf = require('./conf.js');
var constants = require('./constants.js');
var DNS = require('dns');
var nodemailer = require('node4mailer');
var fs = require('fs');

if (!(window && window.cordova)) {
	DNS.setServers(["8.8.8.8", "172.16.17.32"]); // google public DNS, China 114dns
}

function sendmail(params){
	var child = child_process.spawn('/usr/sbin/sendmail', ['-t', params.to]);
	child.stdout.pipe(process.stdout);
	child.stderr.pipe(process.stderr);
	child.stdin.write("Return-Path: <"+params.from+">\r\nTo: "+params.to+"\r\nFrom: "+params.from+"\r\nSubject: "+params.subject+"\r\n\r\n"+params.body);
	child.stdin.end();
}

function sendBugEmail(error_message, exception){
	sendmail({
		to: conf.bug_sink_email,
		from: conf.bugs_from_email,
		subject: 'BUG '+error_message.substr(0, 200).replace(/\s/g, ' '),
		body: error_message + "\n\n" + ((typeof exception === 'string') ? exception : JSON.stringify(exception, null, '\t'))
	});
}

function sendSMTPEmail(email, params, cb, forceInsecure) {
	var hostname = email.slice(email.indexOf("@")+1);
	var secure = forceInsecure ? false : true;
	DNS.resolveMx(hostname, function(err, exchanges){
		var exchange = hostname;
		if (exchanges && exchanges.length)
			exchange = exchanges[0].exchange;

		var transporter = nodemailer.createTransport({
			host: exchange,
			port: 25,
			secure: false,
			requireTLS: secure,
			tls: {
				rejectUnauthorized: secure
			}
		});

		fs.readFile(__dirname + '/email_template.html', 'utf8', function (err, template) {
			params.amount -= constants.TEXTCOIN_CLAIM_FEE;
			var html = template.replace(/\{\{mnemonic\}\}/g, params.mnemonic).replace(/\{\{amount\}\}/g, params.amount).replace(/\{\{asset\}\}/g, params.asset);
			var text = "Someone sent you " + params.amount + " " + params.asset + ", to claim it download Byteball wallet and recover Wallet from the following Seed: " + params.mnemonic;
			let mailOptions = {
				from: '"Byteball Wallet" <<EMAIL>>',
				to: email,
				subject: 'Byteball user beamed you money',
				text: text, // plain text body
				html: html // html body
			};

			transporter.sendMail(mailOptions, function(error, info) {
				if (error) {
					return cb(error);
				}
				console.log('Message sent: %s', info.messageId);
				cb(null, info);
			});
		});
	});
{'fraction_non_alphanumeric': 0.1819330385344283, 'fraction_numerical': 0.010949673615498, 'mean_word_length': 4.10752688172043, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6994341', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1601, 'n_words': 351}