Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
inboxとnodemailerをっかって空メール登録みたぃなゃっ
var inbox = require('inbox');
var config = require('./config.json');
var imap = inbox.createConnection(
false, 'imap.gmail.com', {
secureConnection: true,
auth: config.mail.auth
}
);
imap.on('connect', function(){
console.log('connected');
imap.openMailbox('INBOX', function(error){
if(error) throw error;
});
});
imap.on('new', function(message){
console.log(message.from);
console.log(message.date);
//ここでなんかメールの内容をdbに保存したりするo
//その保存とかがぉゎったら、次に返事をだすo
var nodemailer = require('nodemailer');
var smtp = nodemailer.createTransport('SMTP', {
port: 465,
host: 'smtp.gmail.com',
secureConnection: true,
auth: config.mail.auth
});
smtp.sendMail({
from: 'ぁゃぴぼっと<' + config.mail.auth.user + '>',
to: message.from.address,
subject: "ぁりがと",
text: "登録したょ"
}, function(e, res){
console.log(e ? e.message : res.message);
smtp.close();
});
});
imap.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment