https://github.com/dresende/node-smtp
Simple SMTP client for NodeJS
https://github.com/dresende/node-smtp
Last synced: 10 months ago
JSON representation
Simple SMTP client for NodeJS
- Host: GitHub
- URL: https://github.com/dresende/node-smtp
- Owner: dresende
- License: mit
- Created: 2011-04-15T17:52:41.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-02-13T17:14:20.000Z (almost 13 years ago)
- Last Synced: 2025-03-18T17:24:47.893Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 119 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Installation
npm install smtpc
## Usage (require..)
var smtpc = require("smtpc");
## Send an e-mail
Connect to an SMTP server and send e-mails, authenticated or not. You can use the `Client` class
or the `sendmail` function. The later is recommended.
smtpc.sendmail({
"host" : "mail.example.com",
"from" : "john@example.com",
"to" : [ "jane@example.com", "doe@example.com" ],
"auth" : [ "john", "secret" ],
"content" : {
"subject" : "Hello Jane!",
"content-type" : "text/html",
"content" : "Hello Jane!"
},
"success" : function () {
console.log("Sent!");
},
"failure" : function (err) {
console.log("Error(%d): %s", err.code, err.message);
}
});
## Parameters
- `host` (default = "127.0.0.1"): Server to connect to;
- `port` (default = 25): Server port to connect to;
- `auth` (optional): Authentication to use. Should be an array with **username**, **password** and
**method** (optional). Methods supported: **PLAIN**, **LOGIN** and **CRAM-MD5** (default);
- `from` (default = "root@localhost"): Origin e-mail.
- `to`: Destination e-mail(s). It can be a string with one e-mail or an array with all the e-mails.
- `content`: Content of the e-mail. It can be a string or an object with all the e-mail parts (or just 1).
- `contentPath`: If you prefer, you can have the e-mail generated on a file and supply it instead of `content`.
- `success` (optional): Callback invoked when e-mail has successfully been sent.
- `failure` (optional): Callback invoked when some error ocurred.