lolipopを使ってnode.jsでメール送信を行う

lolipopでメール送信を行うメモ。

'use strict';

let nodemailer = require('nodemailer');
let smtpTransport = require('nodemailer-smtp-transport');


let params = {
    from: 'hogehoge@mail.com',
    to: 'foobar@gmail.com',
    subject: 'title',
    text: 'text'
};

let transporter = nodemailer.createTransport(smtpTransport({
     host: 'smtp.lolipop.jp',
     port: 587,
     auth: {
         user: 'hogehoge@mail.com',
         pass: 'xxx',
         auth:'crammd5',
     }
}));

transporter.sendMail(params
  , (err, res)  => {
     if (err) {
          console.log(err);
     } else {
          console.log('メールを送信しました');
     }
});

Related Contents

Pickup Contents