Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- // npm install inbox -save
- // npm install stream -save
- var inbox = require('inbox'),
- Stream = require('stream');
- var client = inbox.createConnection(false, 'mail.bar.es', {
- secureConnection: true,
- auth: {
- user: 'foo@bar.com',
- pass: '123'
- }
- })
- client.on('connect', () => {
- console.info('Conected to server')
- client.openMailbox('INBOX', (err, info) => {
- if (err) {
- console.error('Error opening INBOX: %s', err);
- throw err;
- }
- console.info('Opened INBOX: ', info);
- })
- })
- client.on('new', (message) => {
- console.info('Received message: ', message)
- client.createMessageStream(message.UID).pipe((() => {
- var outStream = new Stream();
- outStream.writable = true;
- outStream.write = (data) => {
- console.info('--- Message content ----')
- console.info('------------------------')
- console.info(new Buffer(data).toString())
- }
- return outStream
- })(), {end: false})
- })
- try {
- client.connect()
- } catch (e) {
- console.error('Error connecting to e-mail inbox: ', e)
- process.exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement