Skip to content

Commit

Permalink
Updated docs etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Andris Reinman committed Feb 10, 2012
1 parent 2ace028 commit 93f2d1f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 11 deletions.
33 changes: 32 additions & 1 deletion README.md
@@ -1,4 +1,35 @@
Nodemailer
==========

This is a project for a new version of Nodemailer, built from scratch.
This is a project for a new version of Nodemailer, built from scratch.

## Well known services for SMTP

If you want to use a well known service as the SMTP host, you do not need
to enter the hostname or port number, just use the 'service' parameter.

Currently cupported services are:

* **"Gmail"** for Google Mail
* **"hot.ee"** for www.hot.ee
* **"Hotmail"** for Microsoft Live Hotmail
* **"iCloud"** for Apple iCloud
* **"mail.ee"** for www.mail.ee
* **"Postmark"** for Postmark App
* **"SendGrid"** for SendGrid
* **"SES"** for Amazon SES
* **"Yahoo"** for Yahoo Mail
* **"Zoho"** for Zoho Mail

Predefined service data covers 'host', 'port' and secure connection settings,
any other parameters (ie. auth) need to be set separately.

For example:

var transport = new nodemailer.Transport("SMTP", {
service: "Gmail",
auth: {
user: "gmail.user@gmail.com",
pass: "password"
}
});
3 changes: 2 additions & 1 deletion examples/example_ses.js
Expand Up @@ -3,7 +3,8 @@ var nodemailer = require('../lib/mail');
// Create an Amazon SES transport object
var transport = new nodemailer.Transport("SES", {
AWSAccessKeyID: "AWSACCESSKEY",
AWSSecretKey: "/AWS/SECRET"
AWSSecretKey: "/AWS/SECRET",
ServiceUrl: "https://email.us-east-1.amazonaws.com" // optional
});

console.log('SES Configured');
Expand Down
2 changes: 1 addition & 1 deletion examples/example_smtp.js
Expand Up @@ -2,7 +2,7 @@ var nodemailer = require('../lib/mail');

// Create a SMTP transport object
var transport = new nodemailer.Transport("SMTP", {
service: 'gmail', // use well known service
service: 'Gmail', // use well known service
auth: {
user: "test.nodemailer@gmail.com",
pass: "Nodemailer123"
Expand Down
9 changes: 5 additions & 4 deletions lib/engines/ses.js
Expand Up @@ -66,15 +66,15 @@ SESTransport.prototype.handleMessage = function(email, callback) {

//Execute the request on the correct protocol
if(urlparts.protocol.substr() == "https:") {
request = https.request(reqObj, this.buildResponseHandler.bind(this, callback));
request = https.request(reqObj, this.responseHandler.bind(this, callback));
} else {
request = http.request(reqObj, this.buildResponseHandler.bind(this, callback));
request = http.request(reqObj, this.responseHandler.bind(this, callback));
}
request.end(params);
}

//Adds the callback to the response handler's scope
SESTransport.prototype.buildResponseHandler = function(callback, response) {
SESTransport.prototype.responseHandler = function(callback, response) {
var body = "";
response.setEncoding('utf8');

Expand All @@ -98,6 +98,8 @@ SESTransport.prototype.buildResponseHandler = function(callback, response) {
});
}

// It really sucks but I don't know a good way to stream a POST request with
// unknown legth, so the message needs to be fully composed as a string
SESTransport.prototype.generateMessage = function(emailMessage, callback) {
var email = "";

Expand All @@ -111,7 +113,6 @@ SESTransport.prototype.generateMessage = function(emailMessage, callback) {
});

emailMessage.streamMessage();

}

SESTransport.prototype.buildKeyValPairs = function(config){
Expand Down
38 changes: 34 additions & 4 deletions lib/wellknown.js
@@ -1,19 +1,21 @@

/*
* This is a collection of well known SMTP service providers
*/

module.exports = {
"gmail":{
"Gmail":{
host: "smtp.gmail.com",
secureConnection: true,
port: 465,
requiresAuth: true
},
"yahoo":{
"Yahoo":{
host: "smtp.mail.yahoo.com",
secureConnection: true,
port: 465,
requiresAuth: true
},
"hotmail":{
"Hotmail":{
host: "smtp.live.com",
port: 587,
requiresAuth: true
Expand All @@ -25,5 +27,33 @@ module.exports = {
"mail.ee":{
host: "smtp.mail.ee",
requiresAuth: true
},
"SES":{
host: "email-smtp.us-east-1.amazonaws.com",
secureConnection: true,
port: 465,
requiresAuth: true
},
"Zoho":{
host: "smtp.zoho.com",
secureConnection: true,
port: 465,
requiresAuth: true
},
"iCloud":{
host:"smtp.mail.me.com",
port: 587,
requiresAuth: true
},
"SendGrid":{
host: "smtp.sendgrid.net",
secureConnection: true,
port: 465,
requiresAuth: true
},
"Postmark":{
host: "smtp.postmarkapp.com",
port: 25,
requiresAuth: true
}
}

0 comments on commit 93f2d1f

Please sign in to comment.