Skip to content

Instantly share code, notes, and snippets.

@cowholio4
Last active December 26, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowholio4/1841ffae55f747bb3b3837e327632f13 to your computer and use it in GitHub Desktop.
Save cowholio4/1841ffae55f747bb3b3837e327632f13 to your computer and use it in GitHub Desktop.
Simple SES Lambda Rule for collecting/filtering spam. https://www.seclytics.com/blog/2017/12/19/amazon-web-services-ses-spam-honeypot/
def is_spam(event, context):
ses_notification = event['Records'][0]['ses']
message_id = ses_notification['mail']['messageId']
receipt = ses_notification['receipt']
print('Processing message:', message_id)
is_spam = (receipt['spamVerdict']['status'] == 'FAIL' or
receipt['virusVerdict']['status'] == 'FAIL')
if is_spam:
print('SPAM message:', message_id)
else:
print('HAM message:', message_id)
return is_spam
def spam_filter(event, context):
'''Reject all spam emails'''
print('Starting - inbound-ses-spam-filter')
if is_spam(event, context):
return {'disposition': 'stop_rule'}
def spam_trap_filter(event, context):
'''Collect All Spam Emails'''
print('Starting - inbound-ses-spam-trap-filter')
if not is_spam(event, context):
return {'disposition': 'stop_rule'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment