How to use the nodemailer.SMTP 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 amiklosi / Comicr / app.js View on Github external
require('./controllers/uploadFromWeb.js');
require('./controllers/uploadFromFlickr.js');
require('./controllers/facebook.js');
require('./controllers/sendEmail.js');
require('./controllers/imgur.js');
require('./controllers/formUpload.js');
require('./controllers/file.js');
require('./controllers/downloadImage.js');

app.listen(3000);

console.log('Comicr started on port 3000');

if (process.env.NODE_ENV != 'production') {
	console.log("Using gmail SMTP");
	nodemailer.SMTP = {
		host: "smtp.gmail.com", // required
		port: 465, // optional, defaults to 25 or 465
		use_authentication: true,
		ssl: true,
		user: "miklosi.attila@gmail.com",
		pass: "123bolombika"
	}
}
github anatoliychakkaev / railwayjs.com / node_modules / mailer / lib / mailer.js View on Github external
} catch (e) {
        console.log('Could not init mailer extension, env-specific settings not found in config/mailer.yml');
        console.log('Error:', e.message);
        return;
    }
    if (!settings) {
        return;
    }
    exports.settings = settings;

    switch (settings.mailer) {
    case 'sendmail':
        nodemailer.sendmail = true;
        break;
    case 'smtp':
        nodemailer.SMTP = {
            host: settings.host || "localhost",
            port: settings.port || 25,
            use_authentication: settings.use_authentication || false,
            user: settings.user || '',
            pass: settings.pass || ''
        };
        break;
    }

    // read app/views/emails dir
    var emailsDir = app.root + '/app/views/emails';
    if (path.existsSync(emailsDir)) {
        fs.readdirSync(emailsDir).forEach(function (file) {
            templates[file] = fs.readFileSync(emailsDir + '/' + file).toString('utf8');
        });
    }
github LockerProject / Locker / Apps / Reminisce / app.js View on Github external
request.get({uri:processInfo.lockerUrl+"/Me/photos/allPhotos"},function(err, res, body){
        if(err)
        {
            console.log("failed to get photos: "+err);
            return;
        }
        var photos = JSON.parse(body);
        // ideally this is a lot smarter, about weighting history, tracking to not do dups, etc
        var rand = Math.floor(Math.random() * photos.length);
        console.log("for "+auth.username+" we picked random photo: "+JSON.stringify(photos[rand]));
        // hard coded to gmail for testing (ver -0.1)
        nodemailer.SMTP = {
            host: 'smtp.gmail.com',
            port: 587,
            ssl: false,
            use_authentication: true,
            user: auth.username,
            pass: auth.password
        };
        // Message object
        var cid = Date.now() + '.image.png';
        var message = {
            sender: 'Reminisce <42@awesome.com>',
            to: auth.username,
            subject: 'something fun and random  ✔',
            body: 'Hello to myself!',
            html:'<p><b>reminiscing...</b> <img src="cid:"></p>',
            debug: true,
github bcoe / DoloresLabsTechTalk / server.js View on Github external
request.addListener('response', function (response) {
	    response.setEncoding('binary')
	    var body = '';
	
	    response.addListener('data', function (chunk) {
	        body += chunk;
	    });
	
	    response.addListener("end", function() {
			callback(body);
		});
	});
}

nodemailer.SMTP = {
	host: 'smtp.gmail.com', // required
	use_authentication: true, // optional, false by default
	user: process.env.GMAIL_ACCOUNT, // used only when use_authentication is true 
	pass: process.env.GMAIL_PASSWORD  // used only when use_authentication is true*/
};

function sendMail(imageData, filename, email, callback) {
	
	var attachmentList = [{
		filename: filename,
		contents: new Buffer(imageData, 'binary')
	}];
		
	var mailData = {
		sender: process.env.GMAIL_ACCOUNT,
		to: email,
github LockerProject / Locker / Connectors / SMTP / smtp.js View on Github external
app.post('/save', function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    if(!req.body || !req.body.host || !req.body.port) return res.end("missing minimum required host/port :(");
    nodemailer.SMTP = auth = {host:req.body.host, port:req.body.port, ssl:false};
    if(req.body.ssl) auth.ssl = true;
    if(req.body.user &amp;&amp; req.body.pass)
    {
        auth.use_authentication = true;
        auth.user = req.body.user;
        auth.pass = lcrypto.encrypt(req.body.pass);
    }
    lutil.atomicWriteFileSync("auth.json", JSON.stringify(auth, null, 4));
    if(auth.pass) auth.pass = req.body.pass; // keep around unencrypted
    res.end("saved! <a href="./">continue</a>");
});
github 9958 / NEMBlog / app / lib / util.js View on Github external
exports.send_email = function(to,subject,html){
    var mail = require('nodemailer');  //包含发送邮件所需module
    //发送邮件
    mail.SMTP = settings.smtp;
    mail.send_mail(
        {
            sender:settings.smtp.user,   //发送邮件的地址
            to:to,     //发给谁
            subject:subject,               //主题
            html:html
        },
        //回调函数,用户判断发送是否成功,如果失败,输出失败原因。
        function(error,success){
            if(!error){
                console.log('message success');
                }else{
                console.log('failed'+error);
            }
        }
    );
github statusdashboard / statusdashboard / plugins / mail / mail_plugin.js View on Github external
exports.create = function(api, settings) {
  if (settings.plugins && settings.plugins.mail && settings.plugins.mail.enable) {
    var nodemailer = require('nodemailer');

    console.log('Creating the plugin: ' + __filename);

    nodemailer.SMTP = settings.plugins.mail.options.nodemailer;
    
    var lastCount = 0;
    var lastService = {};

    var mail = function(body) {
      nodemailer.send_mail({
          sender: settings.plugins.mail.sender,
          to: settings.plugins.mail.to,
          subject: settings.plugins.mail.subject,
          //html: body,
          body: body,
          debug: settings.plugins.mail.options.nodemailer.debug
        },
        function(error, success){
          logger.log('Message ' + (success ? 'sent' : 'failed') + ":" + body);
        }
github adrianbravo / jukesy / app / controllers / mail_controller.js View on Github external
module.exports = function(app) {

  var nodemailer = require('nodemailer')
  nodemailer.SMTP = { 
    host: 'localhost'
  }

  return {

    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>"</p>
github sendgrid / sendgrid-nodejs / lib / smtp.js View on Github external
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;
    }