Skip to content

hashmail/imap-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imap-server

An IMAP server in node.js

This project is a work in progress and is just starting. The long term goal is to implement RFC3501 in all its glory.

The current status is that it's a proof of concept good enough to pass Mozilla Thunderbird's checks as a valid IMAP server. It won't actually send any messages yet.

Prior Art

There are many implementations in other high level languages on GitHub, mostly incomplete.

There is also an IMAP command parser extracted from inbox by @andris9

Contributing

At this stage, open an issue and I'll add you to the contributors team so we can get started.

Planned API

The plan is to try and make it really simple to set up an IMAP server. They key is that we want an API that is protocol agnostic so that an identical API can be implemented for POP3. It's very much a work in progress, so don't expect it to stay the same.

var fs = require('fs');
var imap = require('imap-server')

// SSL
var certs = {
    key: fs.readFileSync('./ssl/key.pem'),
    cert: fs.readFileSync('./ssl/cert.pem')
};

// IMAP server

var server = imap({options})

server.authenticate(function (username, password, callback) {
  //authenticate user and either call callback with error as first arg or 'e-mail address' of user as second arg.
})

server.mailBoxes(function (email, queryArgs, callback) {
  //return a list of the users mail boxes
})

server.mailItems(function (email, queryArgs, callback) {
  //return a list of the users mail items
})

server.addMailItem(function (email, mailItem, callback) {
  //write the mail message to the database
})
server.updateMailItem(function (email, mailItem, callback) {
  //write the mail message to the database
})

db.on('message', function (message) {
  //push messages to clients that support some kind of push type protocol
  server.push(message.email, message.body)
})

// port 143
var net = require('net')
net.createServer(server).listen(process.env.IMAP_PORT || 143)
// port 993
var tls = require('tls')
tls.createServer(certs, server).listen(process.env.IMAPS_PORT || 993)

TODO: plugin architecture for the future

License

MIT

About

An IMAP server in node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published