Beispiel #1
0
exports.send = function (to, subject, text, html, callback) {

    var headers = {
        from: Config.email.fromName + ' <' + Config.email.replyTo + '>',
        to: to,
        subject: subject,
        text: text
    };

    var message = Email.message.create(headers);

    if (html) {
        message.attach_alternative(html);
    }

    var mailer = Email.server.connect(Config.email.server);
    mailer.send(message, function (err, message) {

        if (err) {
            if (!callback) {
                return console.log('Email error: ' + JSON.stringify(err));
            }

            return callback(Hapi.error.internal('Failed sending email: ' + JSON.stringify(err)));
        }

        if (callback) {
            return callback(null);
        }
    });
};
Beispiel #2
0
    csv.parse(data, function (err, data) {
        var server = email.server.connect(config);

        var title = data.shift();

        data.forEach(function (item) {
            var email = item.pop();
            var td = item.join('</td><td>');
            td = '<td>' + td + '</td>';
            var th = title.join('</th><th>');
            th = '<th>' + th + '</th>';
            var table = ['<html><table><tr>', th, '</tr><tr>', td, '</tr></table></html>'];
            table = table.join('');
            console.info(table);
            var message = {
                from: 'qiaoliang<*****@*****.**>',
                to: email,
                // cc: einfo.cc
                subject: item[0] + '工资单',
                attachment: [
                    {data: table, alternative: true}
                ]
            };

            server.send(message, function (err, message) {
                console.info('发送邮件成功');
            });
        });
    });
Beispiel #3
0
 pdftk.on('exit', function (code) {
     console.log('child process ended with ' + code);
     if (code != 0)
         return;
     console.log('sending email');
     // отправка сообщения по электронной почте
     var server = emailjs.server.connect({
         user : '******',
         password : '******',
         host : 'smtp.gmail.com',
         port : 587,
         tls : true
     });
     var headers = {
         text : 'You can find your split PDF at ' + url,
         from : 'youremail',
         to : email,
         subject: 'split pdf'
     };
     var message = emailjs.message.create(headers);
     message.attach({
         data:"<p>You can find your split PDF at " + "<a href='" + url + "'>" + url + "</a></p>",
         alternative: true
     });
     server.send(message, function(err, message) {
         console.log(err || message);
     });
     pdftk.kill();
 });
Main.prototype.supportComment = function( req, res ){

	// console.log(req.body.name);
	// console.log(req.body.email);
	// console.log(req.body.msg);

	var emailjs   = require("emailjs");
	var server  = emailjs.server.connect({
	   user:     mailInfo.user, 
	   password: mailInfo.password,
	   host:     mailInfo.host, 
	   ssl:     true
	});

	// send the message and get a callback with an error or details of the message that was sent
	server.send({
	   text:    req.body.msg, 
	   from:    req.body.name + " <" + req.body.email + ">",
	   to:      "Robert Smith with Chromemote <*****@*****.**>", 
	   cc:      "",
	   subject: "Chromemote Support Comment"
	}, function(err, message) { /*console.log(err || message);*/
		res.send(message);
	});
    
}
Beispiel #5
0
 socket.join(socket.room, function() {
    io.sockets.in(socket.room).emit('room.created', room);
    var domain_name = socket.handshake.headers.referer.split('?')[0];
    var email_config = config[utils.nicifyDomain(domain_name)].email;
    var mail_system;
    if(email_config){
       if(email_config.method == "mailgun"){
          if(email_config.mailgun_api_key && email_config.mailgun_domain){
             mail_system = require('mailgun-js')({apiKey: email_config.mailgun_api_key, domain: email_config.mailgun_domain}).messages();
          }
       }else if(email_config.method == "smtp"){
          if("smtp_email" in email_config &&"smtp_pass" in email_config && "smtp_host" in email_config && "smtp_ssl" in email_config){
             mail_system = email.server.connect({
                user: email_config.smtp_email,
                password: email_config.smtp_pass,
                host: email_config.smtp_host,
                domain: email_config.smtp_host,
                ssl: email_config.smtp_ssl,
                port: email_config.smtp_port,
                authentication: email_config.smtp_auth
             });
          }
       }
       invitePeopleToRoom(invitees, domain_name, socket.room.toUpperCase(), pageTitle, user, mail_system, email_config.method, io);
    }
 });
Beispiel #6
0
function email(options, subject, text) {

	if (!send) {
		return;
	}
	if (!options.send && !options) {
		console.log("Not sending message (b/c send=false): "+text)
		return;
	} else {
		console.log("Sending message: "+text)
	}
	
	var server  = emailjs.server.connect({
		user:     user, 
		password: password, 
		host:     host, 
		ssl:      true	
	});
	//console.log(server)
	server.send({
		text:    text, 
		from:    from, 
		to:      options.alertTo || to,
		subject: "URLWatch: " + subject
	}, function(err, message) { 
		if (err) {
			console.log("Error while attempting to send email:")
			console.log(err);
		}
	});
}
			    usersDB.insertAndReturn(userData, function(doc){

			    	var emailjs   = require("emailjs");
					var server  = emailjs.server.connect({
					   user:     mailInfo.user, 
					   password: mailInfo.password,
					   host:     mailInfo.host, 
					   ssl:     true

					});

					// send the message and get a callback with an error or details of the message that was sent
					server.send({
					   text:    "Thanks so much for your contribution to Chromemote. \n\nI have included in this email " +
					   			"an activation key that you can enter into Chromemote's settings to allow you the ability "+
					   			"to turn off the ads. Feel free to leave them enabled as another way to continue support. :)\n\n"+
					   			"User Account:\t"+ userData.email + "\n"+
					   			"Product Key: \t"+ userData.product_key+ "\n\n"+
					   			"Thanks Again,\nRobert Dale Smith\nChromemote Developer\nwww.Chromemote.com \n\n\n"+
					   			"ps. If you enjoy using Chromemote, then please give us a review on the Chrome Web Store: \n https://chrome.google.com/webstore/detail/bhcjclaangpnjgfllaoodflclpdfcegb/publish-accepted/reviews", 
					   from:    "Robert Smith with Chromemote <*****@*****.**>", 
					   to:      userData.name + " <" + userData.email + ">",
					   cc:      "",
					   subject: "Chromemote Product Key Recovery Request"
					}, function(err, message) { /*console.log(err || message);*/ });

			    	var obj = {};
			    	obj = doc;
			    	obj.msg = "OK";
			    	res.send(obj);
			    });	
var Mail = exports.Mail = function (options) {
  options = options || {};

  if (!options.to){
    throw new Error("winston-mail requires 'to' property");
  }

  this.name             = options.name                   || 'mail';
  this.to               = options.to;
  this.from             = options.from                   || "winston@" + os.hostname();
  this.level            = options.level                  || 'error';
  this.unique           = options.unique                 || false;
  this.silent           = options.silent                 || false;
  this.subject          = options.subject ? template(options.subject) : template("winston: {{level}} {{msg}}");
  this.html             = options.html                   || false; //Send mail in html format
  this.sendgridApiKey   = options.sendgridApiKey         || null;

  this.handleExceptions = options.handleExceptions || false;

  if (this.sendgridApiKey){
      this.server  = sendgrid(this.sendgridApiKey);
  }else{
      this.server  = email.server.connect({
          user            : options.username,
          password        : options.password,
          port            : options.port,
          host            : options.host,
          ssl             : options.ssl || options.secure,
          tls             : options.tls,
          timeout         : options.timeout,
          authentication  : options.authentication
      });
  }
};
Beispiel #9
0
module.exports.connect = function(callback) {

	logger.info("Initializing mail service...");
	server = email.server.connect({
	   user:    "******", 
	   password:"", 
	   host:    "127.0.0.1", 
	   ssl:     false
	});

	/*
	send({
		text:    "Crayon instance just started on port " + crayonId, 
		subject: "Crayon Instance (" + crayonId + ") Initializing",
		callback: function(err, message) {
			if (server.ready) {
				logger.info("Mail service is ready");
				callback(null);
			} else {
				var error = "Could not connect to mail server. Please check that the configuration is correct";
				logger.error(error);
				throw new Error(error);
			}
		}
	});
	*/

	callback(null);
};
Beispiel #10
0
function sendComicEndMail(users, host, comicID) {
  var server = mailer.server.connect({
    user: '******',
    password: '******',
    host: 'smtp.gmail.com',
    ssl: true
  })
    , toUsers = "";

  for (var i = 0; i < users.length; i++) {
    toUsers = toUsers + users[i].username + " <" + users[i].email + ">, "
  }

  toUsers = toUsers.slice(0, toUsers.length - 2);

  var message = {
    text: "Je hebt samen met andere gebruikers een strip afgerond.\n\nJe kan de strip bekijken op de volgende URL: http://" + host + "/comic/" + comicID +"\n\nVul alsjeblieft ook de volgende vragenlijst in zodat ik mijn concept kan verbeteren: http://docs.google.com/spreadsheet/viewform?formkey=dEx6WEJPU29sR1ktTTVwRmlVaGV5YUE6MQ",
    from: "Chain Comics <*****@*****.**>",
    to: toUsers,
    subject: "Er is een strip afgerond"
  };

  server.send(message, function(error, message) {
    console.log(error || message);
  });
}
Beispiel #11
0
exports.compose_post = function(req, res){

	if (req.session.authorized == true) {
		address_1 = req.session.address.split("@")
		host = address_1[1]

		try {
			var server  = Email.server.connect({
			   user:    req.session.address, 
			   password: req.session.password, 
			   host:    "smtp."+host, 
			   ssl:     true
			});

			server.send({
			   text:    req.body.message_body, 
			   from:    req.session.address, 
			   to:      req.body.to,
			   cc:      req.body.cc,
			   subject: req.body.subject
			}, function(err, message) { console.log(err || message); });
			
			_message = "Message sent."
			res.redirect('/')
		} catch (e) {
			console.log(e)
			_message = "Message not sent. Message may have not been structured correctly."
			res.redirect('/')
		}
	} else {
		res.redirect('/')
	}
};
Beispiel #12
0
Datei: app.js Projekt: ikoif/site
app.post('/', function(req,res)
{
  // get posted vals
  var name = req.param('name');
  var desc = req.param('desc');
  var email = req.param('email');

  if(email != ''){
    // email
    var serv = emailjs.server.connect({
      user:     "******",
      password: "******",
      host:     "smtp.gmail.com",
      ssl:      true
    });
    // send email
    serv.send({
      text: "Name: "+name+"\nDesc: "+desc+"\nemail: "+email,
      from: "Dodona <ulpianmorina@gmail>",
      to: "*****@*****.**",
      subject: "DODONA - Project Request"
    }, function(err, message) {
      console.log(err || message);
    });
  }
  // response
  res.render('index', { title: 'Dodona', msg: '<div class="btn btn-success" style="cursor:none;">We have received your request and<br> we will get back to you.</div>' });
});
Beispiel #13
0
	}).then(function(token){
		if (!token){
			var error = new Error("Invalid email/username combination.")
			error.status = 403;
			throw error;
		}
		else{
			var server  = email.server.connect({user:"",password:"",host:"mail.instasync.com",ssl:false});
			var url = "http://pr.instasync.com/"+token;
			var message = {
				text: "",
				from: "InstaSync <*****@*****.**>",
				to: "<"+email_address+">",
				subject: "Password reset for " + username,
				attachment:
					[
						{data: "<html><p>A password reset was requested for: <strong>"+username+"</strong>.</p><p>You may reset the password for this account by going to: <br/> <a href='"+url+"'>"+url+"</a></p><p><br/><br/><font size='2'><em>If you did not request a password reset, simply ignore this email as no changes to your current account have been made.</em></font></p></html>", alternative: true}
					]
			};
			return new promise(function(fulfill, reject){
				server.send(message, function(err, message){
					if (err){
						reject(err);
					}
					else
						fulfill();
				});
			});
		}
	}).then(function(){
Beispiel #14
0
Postal.send = function(args,callback) {
	// Assumes all the validations for the email address formats are correct

	var headers	= {
		text		: args.text,
		from		: '"Kriegspiel" <*****@*****.**>',
		to			: args.to.join(','),
		subject		: args.subject
	};

	// Create message
	var message = email.message.create(headers);

	// If an HTML email
	if(args.html) message.attach_alternative(args.html);

	// send the message and get a callback with an error or details of the message that was sent
	var server  = email.server.connect({
			user		: "******",
			password	: secrets.email,
			host		: "binarymax.easycgi.com",
			port		: 587,
			tls			: true
	});

	// send the message and get a callback with an error or details of the message that was sent
	server.send(message, callback);
}
Beispiel #15
0
exports.alert_control = function( celsius ) {
	//Only send if enough time elapsed
	if( Date.now() >= mail_period + last_mail ) {
		
		console.log("Sending alert message!");
		
		var email   = require("emailjs");
		var server  = email.server.connect({
		   user:    "", 
		   password:"", 
		   host:    "smtp.gmail.com", 
		   ssl:     true
		});

		// send the message and get a callback with an error or details of the message that was sent
		server.send({
		   text:    "Temperature is too low ("+celsius+" °C)!", 
		   from:    "", 
		   to:      mail_to,
		   cc:      "",
		   subject: "Balaton temperature alert ("+celsius+" °C)!"
		}, function(err, message) { console.log(err || message); });
		
		//Update the counter
		last_mail = Date.now();
	}

}
Beispiel #16
0
		send: function (templatePath,data,to,subject) {
			var q= Q.defer();

			var server = emailjs.server.connect(JSON.parse(process.env.EMAILJS_CONNECTION_OPTIONS));

			var str = fs.readFileSync(path.join(process.env.rootPath, templatePath), 'utf8');
			var html = ejs.render(str, data);

			server.send({
				text: "",
				from: "noreply@gmail.com <*****@*****.**>",
				to: to,
				subject: subject,
				attachment: [
					{data: html, alternative: true}
				]
			}, function (err, message) {
				if (!err) {
					q.resolve(message);
				}
				else {
					console.log(err);
					q.reject(err);
				}
			});

			return q.promise;
		}
Beispiel #17
0
function sendEmail(body) {
    console.log("--------------------");
    console.log("Sending email");
    console.log(body);

    var server = email.server.connect({
       user:     process.env.SMTP_LOGIN, 
       password: process.env.SMTP_PASSWORD, 
       host:     process.env.SMTP_HOST, 
       ssl:      true
    });

    server.send({
       from:    process.env.EMAIL_FROM, 
       to:      process.env.EMAIL_TO,
       subject: "notification: wedding invitation subscribed",
       text:    body
    }, function(err, message) {
        if (err) { 
            console.log(err); 
        } else { 
            console.log("message sent successuly"); 
        }
    });
}
Beispiel #18
0
  contact: function(req,res){
    var server = emailjs.server.connect({
		user: '******',
		password:'******',
		host: 'smtp.mail.yahoo.com',
		ssl:true
	});
	
	var i;
	var html=
	"<table>";
		for (i in req.body) {
			html +=
			"<tr>"+
				"<td style='text-align:right; padding:5px 20px; font-size:14px; font-weight:bold'>" + i + ":</td><td>" + req.body[i] + "</td>" + 
			"</tr>";
		}
		html +=
	"</table>";
	
	server.send({
		text:html,
		'Content-Type': 'text/html; charse=ISO-8859-1',
		from: '*****@*****.**',
		to: '*****@*****.**',
		subject: 'first email'
	}, function(err, message){
		console.log(err || message);
	});
	
	console.log(req.body);
	
    res.send('');
  },
Beispiel #19
0
  var setupMail = function(err, result) {
    if(result) {
      log.info('Got it.');
      config.password = result.password;
    }

    server = email.server.connect({
      user: config.email,
      password: config.password,
      host: "smtp.gmail.com",
      ssl: true
    });

    if(config.sendMailOnStart) {
      server.send({
        from: "Gekko <" + config.email + ">",
        to: "Bud Fox <" + config.email + ">",
        subject: "Gekko has started",
        text: [
          "I've just started watching the markets, ",
          "I'll let you know when I got some advice"
        ].join('')
      }, send);
    }

    log.debug('Setup email adviser.');
    callback();
  }
Beispiel #20
0
function sendEmail(err) {
    var time = (new Date()).toLocaleString();
    var content = { subject: "备份成功" + time, text: '每日数据备份' };

    //send email
    var server = email.server.connect({
        user: "******",
        password: "******",
        host: "smtp.163.com",
        ssl: true
    });

    var message = {
        from: "blogback <*****@*****.**>",
        to: "xdlysk <*****@*****.**>"
    };

    if (err) {
        content.subject = "备份出错" + time;
        content.text = err.message;
    } else {
        message.attachment =
            [
                { path: "C:/db/back/blog/backup.7z", type: "application/7z", name: "backup.7z" }
            ];
    }
    message.text = content.text;
    message.subject = content.subject;

    // send the message and get a callback with an error or details of the message that was sent
    server.send(message, function(err, message) { console.log(err || message); });
}
Beispiel #21
0
module.exports = async (session, username, templateUrl) => {
    const user = await Node.resolve(ADMIN_SESSION, `/users/${username}`);
    const resetId = await user.generatePasswordReset(ADMIN_SESSION);
    const url = templateUrl.replace("$ID", resetId);
    const server = email.server.connect(config.email);
    const send = util.promisify(server.send).bind(server);

    const text = `
A password reset for the account ${user.attributes.name} has been requested.
Please follow this link to set a new password:
  ${url}
`;
    const html = text.replace(url, `<a href="${url}">${url}</a>`).replace("\n", "<br>");

    await send({
        text,
        from: `no-reply <${config.email.user}>`,
        to: `${user.attributes.name} <${username}>`,
        subject: "Password reset",
        attachment: [
            {
                data: html,
                alternative: true
            }
        ]
    });
};
Beispiel #22
0
function sendMail(code, address, req, res){

   var server  = email.server.connect({
   user:    "******", 
   password:"******", 
   host:    "smtp.gmail.com", 
   ssl:     true
	});
var link = "http://www.hares-build.com/" + code;
var message = {
   text:    "Thank you for thre registration please confirm the registration by clicking the link. " + link, 
   from:    "Hares-build <*****@*****.**>", 
   to:      "<" + address + ">",
   cc:      "else <*****@*****.**>",
   subject: "Hares build registration",

};

// send the message and get a callback with an error or details of the message that was sent
server.send(message, function(err, message) {
	console.log(err || message);
	app.get(link, function(req, res){
		
	})
	res.send() 
 });
}
Beispiel #23
0
router.all('/mail', async function(req, res, next) {
  var lang = res.locals.lang;

  var email = require("emailjs");
  var server = email.server.connect({
    host: "178.159.110.48",
    port: "587",
    user: "******",
    password: "******"
  });

  var message = {
    text: "i hope this works",
    from: "*****@*****.**",
    to: "*****@*****.**",
    cc: "*****@*****.**",
    subject: "testing emailjs",
    attachment: [{
      data: "<html>i <i>hope</i> this works!</html>",
      alternative: true
    }]
  };
  var data = [];
  for (var i = 0; i < 10; i++) {
    data.push(promify(server, server.send, message));
  }
  console.log(data);
  data = await Promise.all(data);

  console.log(data);
  res.send(data);
});
Beispiel #24
0
var Mail = exports.Mail = function (options) {
  options = options || {};

  if (!options.to){
    throw new Error("winston-mail requires 'to' property");
  }

  this.name       = options.name                   || 'mail';
  this.to         = options.to;
  this.from       = options.from                   || "winston@" + os.hostname();
  this.level      = options.level                  || 'info';
  this.silent     = options.silent                 || false;
  this.subject    = options.subject ? template(options.subject) : template("winston: {{level}} {{msg}}");
  this.html       = options.html                   || false; //Send mail in html format

  this.handleExceptions = options.handleExceptions || false;
  this.server  = email.server.connect({
    user            : options.username,
    password        : options.password,
    port            : options.port,
    host            : options.host,
    ssl             : options.ssl || options.secure,
    tls             : options.tls
  });
};
Beispiel #25
0
 function f_server() {
     return email.server.connect({
         user: result.User,
         password: result.Password,
         host: result.Host,
         ssl: result.SSL
     });
 }
Beispiel #26
0
Carrier.prototype.$connect = function $connect () {
    return email.server.connect({
        user: this.$config.user, 
        password: this.$config.password, 
        host: this.$config.host,
        port: this.$config.port,
        ssl: this.$config.ssl
    });
};
Beispiel #27
0
}).then((password) => {
  server = Emailjs.server.connect({
    user: "",
    password: password,
    host: "smtp.gmail.com",
    ssl: true
  });
  server.send(message, (err, message) => console.log(err || message));
});
Beispiel #28
0
 setServer: function () {
     var self = this;
     self.server = email.server.connect({
         user: self.getUser(),
         password: self.password, 
         host: self.host || 'smtp.' + self.from.split('@')[1].split('>')[0], 
         ssl: true
     });
 },
Beispiel #29
0
(function (require, module) {
  'use strict';

  // TODO: Maybe use something like https://github.com/bevacqua/campaign
  // to use Mandrill

  var colors = require('colors');
  var config = require('../../shared/config.js');
  var emailConfig = config.email_settings;
  var Q = require('q');

  if (!emailConfig.enabled) {
    console.log('Email sending not enabled in config.'.yellow);
    return;
  }

  // Persist connection ver multiple imports
  var emailjs = require('emailjs');

  console.log('emailSend.js: Will connect to smtp server at: ' +
    emailConfig.host + ':' + emailConfig.port);

  var server = emailjs.server.connect({
    user: emailConfig.user,
    password: emailConfig.password,
    host: emailConfig.host,
    port: emailConfig.port,
    ssl: emailConfig.ssl,
    tls: false
  });

  module.exports = {
    sendText: function (data, next) {
      var deferred = Q.defer();

      // Send simple text string in an email.
      // Templating is done as a seperate step using express app.render()
      if (!server) {
        console.log('Cannot send email: Email sending is disabled.'.red);
        deferred.resolve(); // Resolve instead of error because it is expected
        return;
      }

      server.send(data, function (err, message) {
        if (err) {
          deferred.reject(err);
        } else if (message) {
          deferred.resolve(message);
        }
      });

      return deferred.promise;
    }
  };

})(require, module);
Beispiel #30
0
	app.post('/contact', function(req, res) {
		var email=[];    
		var checkSignup = req.body.signupCheck;
		var name = req.body.name;
		var info = req.body.info;
    
    	email.push(req.body.email);

		console.log("email received: %s", email[0]);
		console.log("Sign Up Check: %s", checkSignup);

		//Store Email if User requested by checking the checkbox
		if(checkSignup) {
			//Function to store email Async to the database.
			async.forEach(email, Help.storeEmail, function(err) {
				if (err) {
					console.log(err);
					response.send("error storing emails");
				} else {
					// email added successfully
					//response.redirect("/orders");
					console.log("Email added successfuly to database");
				}
			}); 
		}
    	console.log("E_User: "******"smtpout.secureserver.net", 
			ssl:     true
		});
 
		// send the message and get a callback with an error or details of the message that was sent
		var message = {
		   text:    "Thanks for contacting us! We have receive your message and we will contact you as soon as possible.  We received the following information:"
					+"Name: "+ name + ", Email: "+ email[0] + ", Information Requested: "+ info, 
		   from:    "ToolSpin <*****@*****.**>", 
		   to:      name + " <"+email+">",
		   cc:      "ToolSpin <*****@*****.**>",
		   subject: "Information Request Confirmation",
		   attachment: 
		   [
			  {data:"<html>Thanks for contacting us! We have receive your message and we will contact you as soon as possible.<br>"
			  +"We received the following information:<br><br>"
			  +"<strong>Name: </strong>"+name+"<br>"
			  +"<strong>Email: </strong>"+email+"<br>"
			  +"<strong>Information Requested: </strong>"+info+"<br></html>", alternative:true}
		   ]
		};
	
		// send the message and get a callback with an error or details of the message that was sent
		server.send(message, function(err, message) { console.log(err || message); }); 
	});