Permalink
Browse files

Added STS support for AWS SES requests.

Fixed AWS requests not working through command line interface.
  • Loading branch information...
1 parent 8911552 commit 588e005f5223696e573876db2a93e6bc5e8b2881 @Jimbly Jimbly committed Mar 6, 2013
Showing with 14 additions and 7 deletions.
  1. +6 −5 bin/nodemailer
  2. +8 −2 lib/engines/ses.js
View
11 bin/nodemailer 100755 → 100644
@@ -24,6 +24,7 @@ if(argv.help){
console.log("Amazon SES options");
console.log(" --key=[AWSKey] Amazon SES key");
console.log(" --secret=[AWSSecret] Amazon SES secret");
+ console.log(" --token=[STS Token] Amazon SES security token if using STS");
console.log("");
console.log("Mail options");
console.log(" --from=[address] Sender of the mail");
@@ -59,7 +60,8 @@ var transportType = (argv.transport || configFile.transport || process.env.NODE
port = argv.port || configFile.port || process.env.NODEMAILER_PORT,
secure = (argv.secure || configFile.secure || process.env.NODEMAILER_SECURE || "").toString().toLowerCase().trim(),
key = argv.key || argv.k || configFile.key || process.env.NODEMAILER_KEY,
- secret = argv.secret || configFile.secret || process.env.NODEMAILER_SECRET;
+ secret = argv.secret || configFile.secret || process.env.NODEMAILER_SECRET
+ token = argv.token || configFile.token || process.env.NODEMAILER_TOKEN;
if(!transportType){
transportType = host?"smtp": (key?"ses":"sendmail");
@@ -86,10 +88,9 @@ switch(transportType.toUpperCase().trim()){
}
break;
case "SES":
- transportOptions.auth = {
- AWSAccessKeyID: key,
- AWSSecretKey: secret
- }
+ transportOptions.AWSAccessKeyID = key;
+ transportOptions.AWSSecretKey = secret;
+ transportOptions.AWSSecurityToken = token;
}
var transport = nodemailer.createTransport(transportType, transportOptions);
View
@@ -71,12 +71,18 @@ SESTransport.prototype.handleMessage = function(email, callback) {
urlparts = urllib.parse(this.options.ServiceUrl),
- params = this.buildKeyValPairs({
+ pairs = {
'Action': 'SendRawEmail',
'RawMessage.Data': (new Buffer(email, "utf-8")).toString('base64'),
'Version': '2010-12-01',
'Timestamp': this.ISODateString(date)
- }),
+ };
+
+ if (this.options.AWSSecurityToken) {
+ pairs['SecurityToken'] = this.options.AWSSecurityToken;
+ }
+
+ var params = this.buildKeyValPairs(pairs),
reqObj = {
host: urlparts.hostname,

0 comments on commit 588e005

Please sign in to comment.