/* Configuration */
var config = require("./config");

var email = require("../node_modules/emailjs/email.js");
var server = email.server.connect({
  user: config.smtp.username,
  password: config.smtp.password,
  host: "smtp.gmail.com",
  ssl: true
});

exports.sendRegistrationEmail = function sendEmail(name, email, hash) {
	server.send({
	   text: "Welcome to CodeBuddy, verify your registration under this link " + config.hostname + "/register/" + hash,
	   from: "CodeBuddyWeb <codebuddyweb@gmail.com>",
	   to: name + " <" + email + ">",
	   subject: "CodeBuddy registration"
	}, function(err, message) {
		if (err) console.log("ERROR", "sending email:", err);
		else console.log("INFO", "successfully sent email:", message);
	});
}

exports.sendLoginEmail = function sendEmail(name, email, password) {
	server.send({
	   text: "Welcome to CodeBuddy, your default password is: " + password + " login at " + config.hostname + "/login",
	   from: "CodeBuddyWeb <codebuddyweb@gmail.com>",
	   to: name + " <" + email + ">",
	   subject: "CodeBuddy registration"
	}, function(err, message) {
		if (err) console.log("ERROR", "sending email:", err);
		else console.log("INFO", "successfully sent email:", message);
	});
}

exports.sendForgotPassword = function sendEmail(name, email, password) {
	server.send({
	   text: "CodeBuddy, your new password is: " + password + " login at " + config.hostname + "/login",
	   from: "CodeBuddyWeb <codebuddyweb@gmail.com>",
	   to: name + " <" + email + ">",
	   subject: "CodeBuddy registration"
	}, function(err, message) {
		if (err) console.log("ERROR", "sending email:", err);
		else console.log("INFO", "successfully sent email:", message);
	});
}
@@ -1041,36 +1041,32 @@
  %22CodeBuddy 
-registration
+password
 %22%0A%09%7D, functi
@@ -1509,36 +1509,32 @@
  %22CodeBuddy 
-registration
+password
 %22%0A%09%7D, functi

update email topics