const path = require('path');
const nodemailer = require("nodemailer");
var Config = require(path.join(__dirname, '../../config'));

const Sendmail = class {
    
    constructor() {   
        console.log('Sendmail Controller INIT');
    }

    send( username, email, token ) {
	
	const transporter = nodemailer.createTransport(Config.sendmail);

	const info = transporter.sendMail({
    		from: '"GAMES SUPPORT" <support@iron-brain.ru>', 
    		to: email, 
    		subject: "Confirm registration.",
    		text: "Hello, "+username+". Confirm registration by link. https://pdfgen.evpak-soft.ru/api/v1/confirm/?token="+token,
    		html: "<p>Hello, "+username+". Confirm registration by link.</p><p>[<a href='https://pdfgen.evpak-soft.ru/api/v1/confirm/?token="+token+"'>https://pdfgen.evpak-soft.ru/api/v1/confirm/?token="+token+"</a>]</p>",
  	});

  	console.log("Message sent: %s", info.messageId);

    }

}

module.exports = Sendmail;
