Created
February 2, 2014 15:54
-
-
Save ayapi/8770396 to your computer and use it in GitHub Desktop.
inboxとnodemailerをっかって空メール登録みたぃなゃっ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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