Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No option to filter or mark mails using SES verdicts #29

Open
theo-beers opened this issue Aug 4, 2016 · 3 comments
Open

No option to filter or mark mails using SES verdicts #29

theo-beers opened this issue Aug 4, 2016 · 3 comments

Comments

@theo-beers
Copy link

There seems to be no filter using the SES verdicts. I would like to be able not to forward SPAM or VIRUS verdicts, an/or mark forwarded mails with a [SPAM], [VIRUS], [SUSPICIOUS] in the subject.

I can write some code for this, but I'm no NodeJS expert.

SES doc: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications-contents.html#receiving-email-notifications-contents-receipt-object

@chriselsen
Copy link

Add the following code after line 59:

var dataReceipt = data.event.Records[0].ses.receipt;
    if ( dataReceipt.spamVerdict.status !== 'PASS' ||
        dataReceipt.dkimVerdict.status !== 'PASS' ||
        dataReceipt.spfVerdict.status !== 'PASS' ||
        dataReceipt.virusVerdict.status !== 'PASS' ) {  
            data.log({message: "parseEvent() Verdict check failed:",
            level: "error", event: JSON.stringify(dataReceipt)});
            data.context.fail('Error: Verdict check failed.');
            return;
    }

This will filter out messages with corresponding SES verdicts.

If you want to add a string to the subject line instead, add this to line 199:

    var dataReceipt = data.event.Records[0].ses.receipt;
    if ( dataReceipt.spamVerdict.status !== 'PASS' ||
        dataReceipt.dkimVerdict.status !== 'PASS' ||
        dataReceipt.spfVerdict.status !== 'PASS' ) {
        header = header.replace(
            /^Subject: (.*)/mg,
            function(match, subject) {
                return 'Subject: [SPAM] ' + subject;
            }
        );
    }

@shershams
Copy link

Any plans to integrate this into the code?

@ianrenton
Copy link

+1 from me. Without the spam check, because this script is re-sending from noreply@my-domain.com, I am worried that it is going to appear to recipients that my-domain.com is sending a lot of spam!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants