aws-lambda-ses-forwarder
aws-lambda-ses-forwarder copied to clipboard
Support ability to ignore emails originating from verified domains/email addresses
Awesome work, there is only one thing that I would like to see different. If I am sending a mail from, say, a PHP app to a user, let's say a notification, I want this script to ignore this email and not change it and just let it pass through unharmed. If it comes from another domain not in my list of verified domains then it should do its thang.
Forgive me if there is already a way of doing this. If not then this is something I would love to see.
This point only actually applies to emails that get double routed internally, i.e. I send from [email protected] to [email protected] which then forwards to sammaye@my_awesome_personal_mail.com
I made a simple change in the way the from header is parsed and processed which seems to do the job:
header = header.replace(
/^From: (.*(?:\r?\n\s+.*)*)/mg,
function(match, from) {
var fromText;
var fromEmailDomain = from.replace(/(.*)</, '').replace(/.*@/, "").replace('>', '').trim();
if(data.config.verifiedDomains.indexOf(fromEmailDomain) === -1){
if (data.config.fromEmail) {
fromText = 'From: ' + from.replace(/<(.*)>/, '').trim() +
' <' + data.config.fromEmail + '>';
} else {
fromText = 'From: ' + from.replace('<', 'at ').replace('>', '') +
' <' + data.originalRecipient + '>';
}
} else {
fromText = 'From: ' + from;
}
return fromText;
});
I think it should not task for this script, because your issue is about very specify case.
You can create extension through overriding methods and overide processMessage
method.
Ok, kool.
Though adding "at" for emails routed through verified domains could be classed as slightly buggy which is what I found, since you wouldn't expect that, you would only expect this script to do that behaviour when it receives content from non-verified domains.