Ejemplo n.º 1
0
Archivo: app.js Proyecto: manzoid/nko11
        cb: function(err, card) {
          res.redirect('/card/'+card.uuid+'/sign');
          
          //send emails

          var card_url = 'http://bearshark.nko2.nodeknockout.com/card/'+card.uuid;
          //to the recip
          email.send_mail({
              to: card.to_email,
              sender: '"Greetings Cardling" <*****@*****.**>',
              subject: "A greeting card has been created just for you.",
              html: "Greetings "+card.to_email+",<br /><br />You have recieved <a href=\""+card_url+"\">a card<a/>. Why not take a peek and see who's signing it?<br />The card can be found at: <a href=\""+card_url+"\">"+card_url+"</a><br /><br />---<br /><br />This is an automated message from <a href=\"http://bearshark.nko2.nodeknockout.com/\">Greetings Cardling</a><br/>a project written for <a href=\"http://nodeknockout.com/\">Node Knockout</a>."
          }, function(err, res) {
            if (err) console.log(err);
          });
          
          //to creator
          email.send_mail({
                to: card.from_email,
                sender: '"Greetings Cardling" <*****@*****.**>',
                subject: "Information about the greeting card you created.",
                html: "Greetings,<br /><br />You created a greeting card so we wanted to provide you with some information.<br /><br />Because this is collaborative you may want to share this with friends of "+card.to_name+". To do so just copy "+card_url+"/sign and paste it into your social media outlet or email client and fire away.<br/><br/>You can also see who else has signed <a href=\""+card_url+"\">the card you made</a>.<br />The card can be found at: <a href=\""+card_url+"\">"+card_url+"</a><br /><br />---<br /><br />This is an automated message from <a href=\"http://bearshark.nko2.nodeknockout.com/\">Greetings Cardling</a><br/>a project written for <a href=\"http://nodeknockout.com/\">Node Knockout</a>."
          }, function(err, res) {
            if (err) console.log(err);
          });

        }
Ejemplo n.º 2
0
exports.sendQuestion = function(questionText){
	var nodemailer = require('nodemailer');

	// one time action to set up SMTP information
	nodemailer.SMTP = {
	    host: 'smtp.sendgrid.net'
	}
	
	// send an e-mail
	nodemailer.send_mail(
	    // e-mail options
	    {
	        sender: '*****@*****.**',
	        to:'*****@*****.**',
	        subject:'Question about your apt listing',
	        html: '<p><b>Hi,</b> You have a message about your Craigslist Listing.</p><p>The question is: <BR>' + questionText + '</p>',
	        body:'Hi, here is some body text?'
	    },
	    // callback function
	    function(error, success){
	        console.log('Question Sent (' + questionText + ') ' + success ? 'sent' : 'failed');
	    }
	);
	
}
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;
		
	this.createServers();
}
Ejemplo n.º 4
0
	col.insert(data, function(err, objs){
		if(err){
			console.log('DB ERROR: ', err);
			callback(false);
			return;
		}
		console.log('Database entry created');
		mailer.send_mail(
			{
				sender: '*****@*****.**',
				to: data.email,
				subject:'Pirates vs Ninjas Quest account activation',
				body:
					'Someone has used this e-mail for registration on pvnquest.tk\n'+
					'If it was you, please click on the link below to activate your account\n'+
					'http://pvnquest.tk/activate?h='+data.verify+'\n\n'+
					'Pirates vs Ninjas Quest Bot\n'
			},
			function(error, success){
				if(error){
					console.log('SEND_MAIL ERROR: ', error);
					callback(false);
					return;
				}
				console.log('Message ' + (success ? 'sent' : 'failed'));
				callback(true);
			}
		);
	});
Ejemplo n.º 5
0
exports.sendMail = function(req, res){
	
	var nodemailer = require('nodemailer');

	// one time action to set up SMTP information
	nodemailer.SMTP = {
	    host: 'smtp.sendgrid.net'
	}
	
	// send an e-mail
	nodemailer.send_mail(
	    // e-mail options
	    {
	        sender: '*****@*****.**',
	        to:'*****@*****.**',
	        subject:'Hello!',
	        html: '<p><b>Hi,</b> how are you doing?</p>',
	        body:'Hi, how are you doing?'
	    },
	    // callback function
	    function(error, success){
	        console.log('Message ' + success ? 'sent' : 'failed');
	    }
	);
	res.render('testmail');
}
Ejemplo n.º 6
0
function send_mail(data,cb){
	console.log(mailer.SMTP);
	mailer.send_mail(data,function(err,success){
		if(err)
			console.log(err);
		return cb(err,success);
	});
}
Ejemplo n.º 7
0
exports.sendmail = function (sendermail,tomail,subject,content) {
    mail.send_mail({
        sender: sendermail,
        to: tomail,
        subject:subject,
        html: content},function(error, success){
        console.log('Message ' + success ? 'sent' : 'failed');
    });
};
Ejemplo n.º 8
0
 function doMailing() {
   nodemailer.send_mail(headers, function (err) {
     if (err) {
       console.error(err.message || 'Didn\'t work');
       return;
     }
     console.log('Sent mail. <(^_^<) W00T!');
   });
 }
Ejemplo n.º 9
0
exports.send = function (options) {
  // Send the e-mail
  try {
      nodemailer.send_mail(options.message, options.callback);
  }
  catch(e) {
      console.log('Caught Exception',e);
  }
}
Ejemplo n.º 10
0
exports.sendEmail = function(receiver, sub, msg){
	email.send_mail({
		sender: "*****@*****.**", 
		to:receiver, 
		subject:sub,
    body:msg},
    
		function(error, success){
			console.log("Message "+(success?"sent":"failed"));
		});
}
Ejemplo n.º 11
0
Archivo: app.js Proyecto: baaghee/poll
	emails.forEach(function(to){
		var from ="Poll <*****@*****.**>"
		nodemailer.send_mail({
			sender: from,
			to: to,
			subject:"New poll",
			html: "<h3>You have been invited to take a new poll</h3><a href='http://poll/"+poll+"'>http://poll/"+poll+"</a>",
			body:''			
		}, function(error, success){
			if(error) return res.json({error:'email failed'});
			res.json({sent:1});
		});
	});
Ejemplo n.º 12
0
 graph.sync(function(err) {
   res.send({"status": "ok", "graph": doc.toJSON()});
   if (err) return;
   // Notify
   var mail = nodemailer.send_mail(message, function(err) {
     if(err) {
       console.log('Error occured');
       console.log(err.message);
       return;
     }
     console.log('Successfully notified collaborator.');
   });
 });
Ejemplo n.º 13
0
  this.send_request = function(sendgrid, files, callback) {
    var attachments = [];

    nodemailer.SMTP = {
        host: 'smtp.sendgrid.net',
        port: 465,
        use_authentication: true,
        ssl: true,
        user: apiUser,
        pass: apiKey,
        debug: true
    }

    var sender = sendgrid.getFromAddress();
    var headers = sendgrid.getHeaders();
    var xsmtpapi = sendgrid.getHeader().toJson();

    if(xsmtpapi != '{}') {
      headers['X-SMTPAPI'] = xsmtpapi;
    }

    if(sendgrid.getFromName()) {
      sender = "'" + sendgrid.getFromName() +  "' " + sendgrid.getFromAddress();
    }

    if(sendgrid.getReplyTo()) {
      headers['Reply-To'] = sendgrid.getReplyTo();
    }

    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);
        }
    );
  }
Ejemplo n.º 14
0
/** Generic mailer .*/
function sendMail(mail, next) {
  nodemailer.send_mail(mail, function(err, success) {
    if(err) {
      log(err);
      next(new Error("wrong smtp information"));
      return;
    }
    if(success) {
      next();
    } else {
      next(new Error("smtp server downs, or refuse to take our email."));
    }
  });
}
Ejemplo n.º 15
0
app.get('/email', function(request, response) {
        nodemailer
		.send_mail({
				   sender: '*****@*****.**',
				   to:'*****@*****.**',
				   subject:'Hello!',
				   html: '<p><b>Hi,</b> how are you doing?</p>',
				   body:'Hi, how are you doing?'
				   },function(error, success){
				   console.log('Message ' + success ? 'sent' : 'failed');
				   }
				   );
        response.end();
        });
Ejemplo n.º 16
0
//TODO send in localeContext
function doSend(email_type, email, site, secret, langContext) {
  if (!templates[email_type]) throw "unknown email type: " + email_type;

  // remove scheme from site to make it more human
  site = url.parse(site).hostname;

  var email_params = templates[email_type];

  var public_url = config.get('public_url') + "/" + email_params.landing + "?token=" + encodeURIComponent(secret),
      GETTEXT = langContext.gettext,
      format = langContext.format;

  if (interceptor) {
    interceptor(email, site, secret);
  } else if (config.get('email_to_console')) {
    // log verification email to console separated by whitespace.
    console.log("\nVERIFICATION URL:\n" + public_url + "\n");
  } else {
    var templateArgs = {
      link: public_url,
      site: site,
      gettext: GETTEXT,
      format: format,
      cachify: cachify
    };

    var mailOpts = {
      // XXX: Ideally this would be a live email address and a response to these email
      // addresses would go into a ticketing system (lloyd/skinny)
      sender: "Persona <*****@*****.**>",
      to: email,
      subject: GETTEXT(email_params.subject),
      text: email_params.template(templateArgs),
      headers: {
        'X-BrowserID-VerificationURL': public_url,
        'X-BrowserID-RelyingParty': site
      }
    };

    if (email_params.templateHTML) {
      mailOpts.html = email_params.templateHTML(templateArgs);
    }

    emailer.send_mail(mailOpts, function(err, success) {
      if (!success) {
        logger.error("error sending email to: " + email + " - " + err);
      }
    });
  }
}
Ejemplo n.º 17
0
mailEvent.on("getMail", function () {
  if (mails.length === 0) {
    return;
  }
  
  //遍歷郵件數組,發送每一封郵件,如果有發送失敗的,就再壓入數組,同時觸發mailEvent事件
  var failed = false;
  var i;
  var len;
  var message;
  var failedMails = [];
  var mail;
  var oldemit;
  
  function cb(message) {
    return function (error, success) {
      if (error) {
        failedMails.push(message);
        failed = true;
      }
    };
  }

  function newEmit(oldemit, mail) {
    return function () {
      oldemit.apply(mail, arguments);
    };
  }

  for (len = mails.length - 1; 0 <= len; len -= 1) {
    message = mails[len];
    mail = undefined;
    try {
      message.debug = false;
      mail = mailer.send_mail(message, cb(message));
    } catch (e) {
      failedMails.push(message);
      failed = true;
    }
    if (mail) {
      oldemit = mail.emit;
      mail.emit = newEmit(oldemit, mail);
    }
  }
  if (failed) {
    clearTimeout(timer);
    mails = failedMails;
    timer = setTimeout(trigger, 60000);
  }
});
Ejemplo n.º 18
0
function sendMail (user, callback) {
	// body...
	mailer.send_mail({
		//ssl: true,                        // for SSL support - REQUIRES NODE v0.3.x OR HIGHER
		//domain : "hidden.com",            // domain used by client to identify itself to server
		to : user + "@gmail.com",
		sender: testMailFrom,
		subject : testMailTitle,
		body: testMailMsg
	},
	function(err, result){
		callback(err, result);
	});
}
Ejemplo n.º 19
0
 user.save(function(err, user) {
   if(user) {
     // Send user an email to reset their password
     var nodemailer = require('nodemailer')
       , emailSignature = require('../lib/email-signature')
       , htmlMsg = ''
           + '<p>' + user.name.first + ',</p>'
           + '<p>You can reset your password by clicking the unique link below:</p>'
           + '<p><a href="http://yourdomain.com/reset-password/' + user.random_string + '" target="_blank" title="Reset your password">'
           + 'http://yourdomain.com/reset-password/' + user.random_string + '</a></p>'
           + emailSignature("html")
       , plainMsg = ''
           + user.name.first + ',\n\n'
           + 'You can reset your password by clicking the unique link below:\n\n'
           + 'http://yourdomain.com/reset-password/' + user.random_string + '\n\n'
           + emailSignature("text");
     nodemailer.SMTP = {
         host: 'smtp.gmail.com'
       , port: 465
       , ssl: true
       , use_authentication: true
       , user: '******'
       , pass: '******'
     };
     nodemailer.send_mail(
       {
           sender: '"Llamas" <*****@*****.**>'
         , to: req.form.email
         , subject: user.name.first + ', reset your password using this link'
         , html: htmlMsg
         , body: plainMsg
       },
       function(err, success) {
         if(success) {
           req.flash('success', ''
             + 'An email has been sent to '
             + '<strong>' + req.form.email + '</strong> '
             + 'with a link to reset the account\'s password');
         } else {
           req.flash('error', 'An error occured, please try again');
         }
         res.redirect('/forgot-password');
       }
     );
   } else {
     console.log(err);
     req.flash('error', 'An error occured, please try again');
   }
 });
Ejemplo n.º 20
0
					self.client.zincrby(self.master_tag, 0, self.tag + i, function (err, score) {
						if (score < 1) {
							var d = {
								to : config.errors.to,
								sender : config.errors.from,
								subject : config.errors.subject,
								body: "No free rooms. Adding one now at " + i
							};
							email.send_mail(d, function (err, result) {
								if (err) {
									console.log(err);
								}
							});
						}
					});
Ejemplo n.º 21
0
 email: function(data, done) {	
     //send the email
     nodemailer.send_mail({
         sender: data['sender'], 
         to: data['to'],
         subject: data['subject'],
         body: data['body']
     },
     function(error, success){
         console.log("Message "+(success?"sent":"failed"));
         console.log(error);
         //fire done message
         done();
     });
 }
Ejemplo n.º 22
0
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);
    })
});
Ejemplo n.º 23
0
fu.mail = function(data) { 
    return nodemailer.send_mail(
    // e-mail options
    {
        sender: data.from,
        to: data.to,
        subject:'the402 Mail',
        html: '<p>'+data.msg+'</p>',
        body: data.msg
    },
    // callback function
    function(error, success){
        //sys.puts('Message ' + success ? 'sent ' + data.to : 'failed');
        return success ? true : false;
    });
}
Ejemplo n.º 24
0
module.exports.send = function(msg){
	if(!msg.sender){
		msg.sender = '*****@*****.**';
	}
	if(process.env.NODE_ENV === 'development'){
		console.log(msg);
	}else{
		nodemailer.send_mail(msg,function(err, success){
			if(err || !success){
				console.log('Could not send Message');
				console.log(msg);
				console.log(err);
			}
		});
	}
};
Ejemplo n.º 25
0
emailAlert = function(msg){
	if(config.email_smtp){
		email.send_mail({
			sender: config.email_options.sender,
			to: config.email_options.recipient,
			subject: msg.subject,
			body: msg.body
		},
		function(err,result){
			if(err) console.log(err);	
				return;
		});
	}else{
		console.log("Cannot email, no config setup");
	}
}
Ejemplo n.º 26
0
 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!');
         }
     });
 });
Ejemplo n.º 27
0
      graph.sync(function(err) {
        // Message object
        var message = {
          sender: 'Substance <*****@*****.**>',
          to: user.get('email'),
          subject: 'Reset your Substance password',
          body: 'In order to reset your password on Substance, click on the link below:\n'+config.server_url+"/reset/"+user.get('username')+"/"+user.get('tan'),
          debug: true
        };

        if (err) return res.send({"status": "error"}, 404);
        
        // Notify
        var mail = nodemailer.send_mail(message, function(err) {
          if (err) return res.send({"status": "error"}, 404);
          res.send({"status": "ok"});
        });
      });
Ejemplo n.º 28
0
exports.send = function(email_config, cb) {
    
    console.log('\n\nAttempting to send Mail...'.yellow)
    
    try{

      nodemailer.send_mail(email_config, function(err,data){
        var result = sendMailHandler(err,data)
        cb && cb(err, result)
      }) // end send_mail()

    }catch(e) {

      console.log('Caught Exception',e);

    }

} // end send
Ejemplo n.º 29
0
urlWatch.prototype.sendMail = function(diff, callback) {
    var me = this,
        mail = this.merge(this.mailConfig, {
            html: diff,
            body: diff,
            attachments: [{
                filename: this.attachmentName || this.fileName,
                contents: this.formatAttachment(this.remoteFileContent)
            }]
        });

    nodemailer.send_mail(mail, function(error, success) {
        if (!error) {
            me.log('--> mail sent:', 'YES'.green);
            callback.call(me);
        } else me.log('--> ' + 'mail error'.red + ':', error);
    });
};
Ejemplo n.º 30
0
	this.send = function(appname, title, message, callback) {
		
		logger.info('sending email', {appname: appname, title: title});

		var htmlMessage = message.replace(/\n/g, '<br>');
		// send an e-mail
		nodemailer.send_mail(

			{
				sender: emailInfo.me.name + '<' + emailInfo.me.email + '>',
				to: emailInfo.receivers.join(', '),
				subject: '[CD] ' + appname +' - ' + title ,
				html: '<h3> Continious Deployment Info - ' + appname + ' </h3>' + htmlMessage,
				body: 'Continious Deployment Info - ' + appname + '\n\n' + message
			},

			callback
		);
	};