How to use the nodemailer.send_mail function in nodemailer

To help you get started, we’ve selected a few nodemailer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nodeGame / nodegame / server / nodegame-server / ServerChannel.js View on Github external
function ServerChannel (options, server, io) {
	
	this.options = options;
	this.server = server;
	this.io = io;
		
	this.name = options.name;
	
	if (options.mail) {
		nodemailer.sendmail = true;
		nodemailer.send_mail({sender: this.name, 
	        				  to: options.mail.to,
					          subject: options.mail.subject,
					          body: "MAIL. For now you cannot change this..."}, // TODO allow for custom body
			    function(error, success){
	            console.log("Message "+(success?"sent":"failed"));
	        });
	}
	
	this.nPlayers = options.nPlayers;
	
	
	this.adminChannel = options.admin;
	this.playerChannel = options.player;
	
	this.port = options.port;
github LockerProject / Locker / Connectors / SMTP / smtp.js View on Github external
app.post('/send', function (req, res) {
    if(!auth) return res.send(false);
    if (!req.body || !req.body.to) return res.send(false);
    console.error("DEBUG SMTP: "+JSON.stringify(req.body));
    var sent = false;
    nodemailer.send_mail(req.body, function(err, ok){
        if(sent) return; // bug in nodemailer will call back multiple times!
        sent=true;
        if(err || !ok){
            console.error('Error occured: '+err);
            return res.send(false);
        }
        res.send(true);
    })
});
github LockerProject / Locker / Apps / Reminisce / app.js View on Github external
request.get({uri:imgurl},function(err, res, body){
                if(err)
                {
                    console.error("failed to get photo "+imgurl);
                    return;
                }
                // this doesn't work, garbles the image somehow, dunno what buffer magic is needed :(
                message.attachments[0].contents = body;
                mail = nodemailer.send_mail(message, function(err, ok){
                    if(err){
                        console.error('Error occured: '+err);
                    }
                    if(ok){
                        console.error('Message sent successfully!');
                    }
                });
            });
        }catch(e) {
github sendgrid / sendgrid-nodejs / lib / smtp.js View on Github external
for(var key in files) {
      attachments.push({filename: key, contents: files[key]});
    }

    var options = {
            sender: sender,
            to: sendgrid.getToString(),
            subject: sendgrid.getSubject(),
            html: sendgrid.getHtml(),
            body: sendgrid.getText(),
            attachments: attachments,
            headers: headers
        };

    nodemailer.send_mail(
        options,
        // callback function
        function(error, success){
            callback(!success, error);
        }
    );
  }
}
github anatoliychakkaev / railwayjs.com / node_modules / mailer / lib / mailer.js View on Github external
function sendEmail (template, data, options) {
    options = options || {};
    data = data || {};
    data.url = exports.settings.url;

    var html = ejs.tmpl(getTemplate(template, 'html', options.locale), data),
        body = ejs.tmpl(getTemplate(template, 'text', options.locale), data),
        self = this,
        email = options.email;

    nodemailer.send_mail({
        sender:  options.from || exports.settings.from,
        to:      options.email,
        subject: options.subject,
        body:    body,
        html:    html
    }, function (err, success) {
        if (success) {
            console.log('=== Email sent');
            console.log(options.subject);
            console.log(body);
        } else {
            console.log(err);
        }
    });
}
github nodester / nodester / scripts / mailer.js View on Github external
function send_email(doc) {
  mailer.send_mail({
    sender  : 'support@nodester.com',
    to      : doc.id,
    subject : 'Password reset request',
    body    : 'Here is your password request token: ' + doc.value.token + '\n\nYou can reset your password via Nodester API or CLI'
  }, function (error, success) {
    console.log(new Date,'Reset password e-mail sent to: ' + doc.id)
    console.log(new Date, 'Message ' + success ? 'sent' : 'failed');
    reset_token(doc)
  });
}
github bcoe / DoloresLabsTechTalk / server.js View on Github external
function sendMail(imageData, filename, email, callback) {
	
	var attachmentList = [{
		filename: filename,
		contents: new Buffer(imageData, 'binary')
	}];
		
	var mailData = {
		sender: process.env.GMAIL_ACCOUNT,
		to: email,
		subject: "Here is an image for you: " + filename,
		body: "Here's that image you asked for.",
		attachments: attachmentList
	}
		
	nodemailer.send_mail(mailData, function(err, success) {
		callback(err, success);
	});
}
github adrianbravo / jukesy / app / controllers / mail_controller.js View on Github external
resetToken: function(user, next) {
      var link = app.set('base_url') + '/user/' + user.username + '/reset/' + user.reset.token

      if (app.set('env') == 'production' || app.set('env') == 'staging') {
        nodemailer.send_mail({
            sender  : '"Jukesy" '
          , to      : user.email
          , subject : 'Reset your password'
          , html    : "<p>Hello, <a href="\&quot;&quot;">" + user.username + "</a>.</p>"
                	  + "<p>Jukesy received a request to reset the password for your account.</p>"
  			            + "<p>If you still wish to reset your password, you may use this link: <br>"
                    + "<a href="\&quot;&quot;">" + link + "</a></p>"
                    + "<p>If your password does not need to be reset, simply ignore this message.</p>"
          , body    : "Hello, " + user.username + ". \n\n"
                	  + "Jukesy received a request to reset the password for your account. \n\n"
  			            + "If you still wish to reset your password, you may use this link: \n"
                    + link + "\n\n"
                    + "If your password does not need to be reset, simply ignore this message. \n\n"
        }, next)
      } else {
        next(false, true)