<commit_before>/* File: helpers.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), <NAME>, 86360 CHASSENEUIL-DU-POITOU, France
 * (<EMAIL>)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */



'use strict';

var config = require('./../../env/config.json');
var URL_REQUEST = process.env.URL_REQUEST || config.URL_REQUEST;


var nodemailer = require('nodemailer');

var smtpTransport = nodemailer.createTransport('SMTP', {
	host: process.env.EMAIL_HOST || config.EMAIL_HOST, // hostname
	secureConnection: true, // use SSL
	port: 465, // port for secure SMTP
	auth: {
		user: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
		pass: process.env.EMAIL_HOST_PWD || config.EMAIL_HOST_PWD
	}
});
// Getting Extension of Files
// exports.getFileExtension = function(filename) {
// 	var path = require('path');
// 	return path.extname(filename);
// };

exports.sendMail = function(req, res) {
	var nodemailer = require('nodemailer');
	var sentMailInfos = req.body;
	// create reusable transport method (opens pool of SMTP connections)
	var smtpTransport = nodemailer.createTransport('SMTP', {
		host: process.env.EMAIL_HOST || config.EMAIL_HOST, // hostname
		secureConnection: true, // use SSL
		port: 465, // port for secure SMTP
		auth: {
			user: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
			pass: <PASSWORD>.EMAIL_HOST_PWD || config.EMAIL_HOST_PWD
		}
	});

	// setup e-mail data with unicode symbols
	var mailOptions = {
		from: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
		to: sentMailInfos.to,
		subject: sentMailInfos.fullName + ' a partagé ' + sentMailInfos.doc + ' avec vous',
		text: sentMailInfos.prenom + ' ' + sentMailInfos.content,
		html: sentMailInfos.prenom + ' ' + sentMailInfos.encoded
	};

	// send mail with defined transport object
	smtpTransport.sendMail(mailOptions, function(error, response) {
		if (error) {
			throw error;
		} else {
			res.send(response);
		}

		// if you don't want to use this transport object anymore, uncomment following line
		//smtpTransport.close(); // shut down the connection pool, no more messages
	});
};
exports.passwordRestoreEmail = function(emailTo, subject, content) {
	var mailOptions = {
		from: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
		to: emailTo,
		subject: subject,
		text: '',
		html: content
	};
	smtpTransport.sendMail(mailOptions, function(error, response) {
		if (error) {
			return false;
		} else {
			return true;
		}
	});
};<commit_msg>jshint api/helpers.js<commit_after>/* File: helpers.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), Boulevard <NAME>, 86360 CHASSENEUIL-DU-POITOU, France
 * (<EMAIL>)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */



'use strict';

var config = require('./../../env/config.json');


var nodemailer = require('nodemailer');

var smtpTransport = nodemailer.createTransport('SMTP', {
	host: process.env.EMAIL_HOST || config.EMAIL_HOST, // hostname
	secureConnection: true, // use SSL
	port: 465, // port for secure SMTP
	auth: {
		user: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
		pass: process.env.EMAIL_HOST_PWD || config.<PASSWORD>
	}
});


exports.sendMail = function(req, res) {
	var nodemailer = require('nodemailer');
	var sentMailInfos = req.body;
	// create reusable transport method (opens pool of SMTP connections)
	var smtpTransport = nodemailer.createTransport('SMTP', {
		host: process.env.EMAIL_HOST || config.EMAIL_HOST, // hostname
		secureConnection: true, // use SSL
		port: 465, // port for secure SMTP
		auth: {
			user: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
			pass: process.env.EMAIL_HOST_PWD || config.EMAIL_HOST_PWD
		}
	});

	// setup e-mail data with unicode symbols
	var mailOptions = {
		from: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
		to: sentMailInfos.to,
		subject: sentMailInfos.fullName + ' a partagé ' + sentMailInfos.doc + ' avec vous',
		text: sentMailInfos.prenom + ' ' + sentMailInfos.content,
		html: sentMailInfos.prenom + ' ' + sentMailInfos.encoded
	};

	// send mail with defined transport object
	smtpTransport.sendMail(mailOptions, function(error, response) {
		if (error) {
			throw error;
		} else {
			res.send(response);
		}

		// if you don't want to use this transport object anymore, uncomment following line
		//smtpTransport.close(); // shut down the connection pool, no more messages
	});
};
exports.passwordRestoreEmail = function(emailTo, subject, content) {
	var mailOptions = {
		from: process.env.EMAIL_HOST_UID || config.EMAIL_HOST_UID,
		to: emailTo,
		subject: subject,
		text: '',
		html: content
	};
	smtpTransport.sendMail(mailOptions, function(error) {
		if (error) {
			return false;
		} else {
			return true;
		}
	});
};
{'fraction_non_alphanumeric': 0.1128850185453959, 'fraction_numerical': 0.005805515239477504, 'mean_word_length': 3.910530482977039, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3356367', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1952, 'n_words': 614}