Skip to content

Commit

Permalink
Added option httpOptions, tagged as v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Sep 16, 2014
1 parent 9f35423 commit f62eea4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.2.0 2014-09-16

Added option `httpOptions` that maps to the object in underlying AWS.SES constructor. See options [here](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html).

## v1.1.0 2014-07-31

Added option `rateLimit` for rate limiting sent messages
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Where
* **secretAccessKey** - *optional* AWS secret.
* **sessionToken** - *optional* session token.
* **region** - *optional* Specify the region to send the service request to. Default to *us-east-1*
* **httpOptions** - A set of options to pass to the low-level AWS HTTP request. See options in the [AWS-SES docs](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html).
* **rateLimit** - *optional* Specify the amount of messages that [can be sent in 1 second](http://docs.aws.amazon.com/ses/latest/DeveloperGuide/limits.html). For example if you want to send at most 5 messages in a second, set this value to 5. If you do not set it, rate limiting is not applied and messages are sent out immediatelly.

**Example**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodemailer-ses-transport",
"version": "1.1.0",
"version": "1.2.0",
"description": "SES transport for Nodemailer",
"main": "src/ses-transport.js",
"scripts": {
Expand Down
12 changes: 8 additions & 4 deletions src/ses-transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ function SESTransport(options) {
this.options.apiVersion = '2010-12-01';
this.options.region = options.region || (result && result[3]) || 'us-east-1';

this.options.rateLimit = Number(options.rateLimit) || false;
if (options.httpOptions) {
this.options.httpOptions = options.httpOptions;
}

this.rateLimit = Number(options.rateLimit) || false;
this.queue = [];
this.sending = false;

Expand All @@ -55,7 +59,7 @@ SESTransport.prototype.send = function(mail, callback) {
// SES strips this header line by itself
mail.message.keepBcc = true;

if (this.options.rateLimit) {
if (this.rateLimit) {
this.queue.push({
mail: mail,
callback: callback
Expand Down Expand Up @@ -92,14 +96,14 @@ SESTransport.prototype.processQueue = function() {
});
}

if (timeDelta >= 1000 / this.options.rateLimit) {
if (timeDelta >= 1000 / this.rateLimit) {
this.sending = false;
setImmediate(this.processQueue.bind(this));
} else {
setTimeout(function() {
this.sending = false;
this.processQueue();
}.bind(this), Math.ceil(1000 / this.options.rateLimit - timeDelta));
}.bind(this), Math.ceil(1000 / this.rateLimit - timeDelta));
}
}.bind(this));
};
Expand Down

0 comments on commit f62eea4

Please sign in to comment.