Skip to content

Commit 4a7b137

Browse files
committed
added subjectPrefix option
1 parent 10199d5 commit 4a7b137

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ console.log("AWS Lambda SES Forwarder // @arithmetric // Version 3.0.0");
77
//
88
// Expected keys/values:
99
// - fromEmail: Forwarded emails will come from this verified address
10+
// - subjectPrefix: Forwarded emails subject will contain this prefix
1011
// - emailBucket: S3 bucket name where SES stores emails.
1112
// - emailKeyPrefix: S3 key name prefix where SES stores email. Include the
1213
// trailing slash.
@@ -17,6 +18,7 @@ console.log("AWS Lambda SES Forwarder // @arithmetric // Version 3.0.0");
1718
// The key must be lowercase.
1819
var defaultConfig = {
1920
fromEmail: "noreply@example.com",
21+
subjectPrefix: "",
2022
emailBucket: "s3-bucket-name",
2123
emailKeyPrefix: "emailsPrefix/",
2224
forwardMapping: {
@@ -184,6 +186,15 @@ exports.processMessage = function(data, next) {
184186
return fromText;
185187
});
186188

189+
// Add a prefix to the Subject
190+
if (data.config.subjectPrefix) {
191+
header = header.replace(
192+
/^Subject: (.*)/mg,
193+
function(match, subject) {
194+
return 'Subject: ' + data.config.subjectPrefix + subject;
195+
});
196+
}
197+
187198
// Remove the Return-Path header.
188199
header = header.replace(/^Return-Path: (.*)\r?\n/mg, '');
189200

0 commit comments

Comments
 (0)