mailx
v0.0.11
Published
simple and complete email client library (pop, imap and smtp) for nodejs
Downloads
326
Readme
Mailx
mailx is a simple and complete email client library (pop, imap and smtp) for nodejs.
Write and send an Email
Message objet
the message object is used to write or read a message.
Sample: write a new message
var message = mailx.message();
message.setFrom('me', '[email protected]');
message.addTo('you', '[email protected]');
message.setSubject('hello');
message.setText('hi ! how are u?');
Transport object
the transport objet is used to send a predefined message.
Sample: sending a message
var transport = mailx.transport('smtp.host.com', 25, 'login', 'password');
transport.send(message, function(err,result) {
console.log(result);
});
Receive Email
Store object
Sample: get all message from server, log their subjets and delete the last one
var store = mailx.store('pop3', 'pop.host.com', 110, 'login', 'password');
store.connect(function(err) {
if (err) {
return console.log('connect error', err);
}
store.getInboxMessages(0, function(err, messages) {
if (err) {
return console.log('inbox error', err);
}
messages.forEach(function(message,index) {
console.log(message.subject);
if (index === messages.length - 1) {
message.delete(function(err, data) {
console.log('message deleted!', data);
store.close(function(err, data) {
console.log('store.close err:', err);
});
});
}
});
});
});