This commit is contained in:
Andris Reinman 2017-10-19 23:33:36 +03:00
parent b53ae97938
commit 0342e5c179
3 changed files with 87 additions and 6 deletions

View file

@ -22,7 +22,7 @@ redis="redis://127.0.0.1:6379/3"
# Optional database name or connection url for ZoneMTA queue database. This is
# used to push outbound emails to the sending queue
#sender="zone-mta"
sender="zone-mta"
#queued="mail"

View file

@ -1,6 +1,6 @@
{
"name": "wildduck",
"version": "1.0.83",
"version": "1.0.84",
"description": "IMAP server built with Node.js and MongoDB",
"main": "server.js",
"scripts": {

View file

@ -3,15 +3,14 @@
'use strict';
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
const crypto = require('crypto');
//const util = require('util');
const chai = require('chai');
const request = require('request');
const fs = require('fs');
//const nodemailer = require('nodemailer');
//const imapHandler = require('../lib/handler/imap-handler');
//const userHandler = require('../lib/handler/user-handler');
const BrowserBox = require('browserbox');
const simpleParser = require('mailparser').simpleParser;
const nodemailer = require('nodemailer');
@ -499,4 +498,86 @@ describe('Send multiple messages', function() {
}
);
});
it('should fetch messages from IMAP', done => {
let imagePng = new Buffer(
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/' +
'//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U' +
'g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC',
'base64'
);
let textTxt = 'Some notes about this e-mail';
let swanJpg = fs.readFileSync(__dirname + '/../examples/swan.jpg');
let checksums = [
crypto
.createHash('md5')
.update(imagePng)
.digest('hex'),
crypto
.createHash('md5')
.update(Buffer.from(textTxt))
.digest('hex'),
crypto
.createHash('md5')
.update(swanJpg)
.digest('hex')
];
const client = new BrowserBox('localhost', 9993, {
useSecureTransport: true,
auth: {
user: 'user4',
pass: 'secretpass'
},
id: {
name: 'My Client',
version: '0.1'
},
tls: {
rejectUnauthorized: false
}
});
client.onerror = err => {
expect(err).to.not.exist;
};
client.onclose = done;
client.onauth = () => {
client.listMailboxes((err, result) => {
expect(err).to.not.exist;
let folders = result.children.map(mbox => ({ name: mbox.name, specialUse: mbox.specialUse || false }));
expect(folders).to.deep.equal([
{ name: 'INBOX', specialUse: false },
{ name: 'Archive', specialUse: '\\Archive' },
{ name: 'Drafts', specialUse: '\\Drafts' },
{ name: 'Junk', specialUse: '\\Junk' },
{ name: 'Sent Mail', specialUse: '\\Sent' },
{ name: 'Trash', specialUse: '\\Trash' }
]);
client.selectMailbox('INBOX', { condstore: true }, (err, result) => {
expect(err).to.not.exist;
expect(result.exists).gte(1);
client.listMessages(result.exists, ['uid', 'flags', 'body.peek[]'], (err, messages) => {
expect(err).to.not.exist;
expect(messages.length).equal(1);
let messageInfo = messages[0];
simpleParser(messageInfo['body[]'], (err, parsed) => {
expect(err).to.not.exist;
checksums.forEach((checksum, i) => {
expect(checksum).to.equal(parsed.attachments[i].checksum);
});
client.close();
});
});
});
});
};
client.connect();
});
});