Skip to content

Instantly share code, notes, and snippets.

@ayapi
Created February 2, 2014 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayapi/8770396 to your computer and use it in GitHub Desktop.
Save ayapi/8770396 to your computer and use it in GitHub Desktop.
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