ThisIsMissEm / node-smtp-client

[DEPRECATED] An SMTP Client & Server module for Node.js
MIT License
38 stars 6 forks source link

Design & Implement High level API #2

Closed ThisIsMissEm closed 14 years ago

ThisIsMissEm commented 14 years ago

This API should abstract a lot away from the evented and deep internals of the protocol, providing the developer with a a short / few-step way to send mail.

Marak commented 14 years ago

currently I'm using a syntax for sending mails that goes something like this:

email.send({ to : "marak.squires@gmail.com", from : "obama@whitehouse.gov", subject : "node_mailer test email", body : "hello this is a test email from the node_mailer" });

the idea is that for simple operations such as getting emails or sending emails we can wrap it all into one method call and pass an options parameter.

this doesnt really take into account adding an event listener when the send or get is complete, so it might make sense to do some node.js magic to add a callback / event listener that will asynchronously fire when the smtp operation completes

ThisIsMissEm commented 14 years ago

The flow would probably be something like:

var email = new (require("./lib/smtp").Client);
email.authenticate("user", "password");
// ...
email.send({to: "joe@test.com", from: "test@test.com", subject: "node smtp mail", body: "Some message body"});
// ...
email.close();

Once you've created a client, it'll hold the connection open, until either SIGTERM or close() is called.