1. 程式人生 > >Block Email Coming From Specific Domains or Email Addresses in Amazon SES

Block Email Coming From Specific Domains or Email Addresses in Amazon SES

'use strict';

const AWS = require('aws-sdk');

exports.handler = (event, context, callback) => {
    console.log('Blocking email filter starting');

    const sesNotification = event.Records[0].ses;
    const messageId = sesNotification.mail.messageId;
    const receipt = sesNotification.receipt;
    const mail = sesNotification.mail;  
 
    // Convert the environment variable into array. Clean spaces from it.
    var blockingListString = process.env.blockingList;
    blockingListString = blockingListString.replace(/\s/g,'');  
    var blockingListArray = blockingListString.split(",");

    // Check if the mail source matches with any of the email addresses or domains defined in the environment variable
    function isListed() {
        var length = blockingListArray.length;
        for(var i = 0; i < length; i++) {
            if (mail.source.endsWith(blockingListArray[i]))
                return true;
        }
        return false;
    }

    console.log('Processing message:', messageId);

        // Processing the message
    if (isListed()) {
            callback(null, {'disposition':'STOP_RULE_SET'});
            console.log('Rejecting messageId: ', messageId, ' - Source: ', mail.source, ' - Recipients: ',receipt.recipients,' - Subject: ', mail.commonHeaders['subject']);
    }
    else {
        console.log('Accepting messageId:', messageId, ' - Source: ', mail.source, ' - Recipients: ',receipt.recipients,' - Subject: ', mail.commonHeaders['subject']);
        callback();
    }
};

相關推薦

Block Email Coming From Specific Domains or Email Addresses in Amazon SES

'use strict'; const AWS = require('aws-sdk'); exports.handler = (event, context, callback) => { console.log('Blocking email filter star

Troubleshoot SMTP Connectivity or Timeout Issues with Amazon SES

2.    Note the output. 3.    If the connection times out, check your local firewall rules, routes, and access control lists (ACLs).

Resolve HTTP 403 Access Denied Error From an S3 Website Endpoint Origin in Amazon CloudFront

{ "Version": "2008-10-17", "Id": "PolicyForCloudFrontPrivateContent", "Statement": [ { "Sid": "Allow-OAI-Access-

Fix problems that block programs from being installed or removed

ive window drive clas The load all tar eat Follow these steps to automatically repair issues including corrupted registry keys that block

Block S3 Traffic from VPC or External IP Address

{ "Version": "2012-10-17", "Id": "VPCe and SourceIP", "Statement": [{ "Sid": "VPCe and SourceIP", "Effect": "Deny",

Use Email to Validate Certificate Domains During ACM Renewal

ACM provides managed renewal for Amazon-issued SSL/TLS certificates. If the certificate was issued by ACM and it is associated to one of the Se

A theory of learning from different domains

本文要解決的問題 在什麼條件下,由源域訓練的分類器能在目標域上取得很好的效果 鑑於目標域中只有少量的標記資料,在訓練過程中,我們應該怎樣利用擁有大量已標記資料的源域使得在測試的時候目標誤差最低。 相關概念 1.域適應(domain adaptation) 域

How can i detect the library image is from front camera or back camera

遇到一個奇怪的問題,iOS 前鏡頭拍的照片,被旋轉了 180度。 解法如下: Your code checks for available cameras on the device. What you need to do is read the metadata for the image after

Ask HN: How do you make sure js from a CDN or a CMS hasn't changed?

SRI won't protect you from:* Someone injecting malicious JS code into your checkout page* Non-static JS includes like Google AnalyticsBut it works well for

Powerful jet discovered coming from 'wrong' kind of star: Strongly magnetic neutron star unexpectedly producing jet of material

Neutron stars are superdense objects, the remnants of massive stars that exploded as supernovas. When in binary pairs with "normal" stars, their powerful

Protect Resources in a CloudFormation Stack From Accidental Deletion or Updates

Set DeletionPolicy attributes By default, all resources in a CloudFormation stack are removed when the stack is deleted. To keep or

Use IAM Roles to Restrict API Calls from Specific IP Addresses

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::account-id:user/&

Set Up an Email Forwarding Rule in Amazon WorkMail

Amazon Web Services is Hiring. Amazon Web Services (AWS) is a dynamic, growing business unit within Amazon.com. We are currently hiring So

Email模組(1)-相簿分享無Email

1. 解決方法 此為Android5.0 Email的新design,在沒有登入任何account時,不能使用email分享。請參考AccountReconciler類中reconcileAccountsInternal()方法。 //modified by HQ_wangshi

agooou [QQ:35327864, email: [email p

    我使用的是串列埠讀卡器,RFID卡是philips的Mifare-M1卡。操作讀卡器,就是操作串列埠裝置。串列埠裝置的基礎只是,請參考 https://www.ibm.com/developerworks/cn/linux/l-serials/ ,此文講得很詳細。

agooou [QQ:35327864, email: [email p

        windows系統中,我們在開啟別人機器共享時,必須用一個使用者登入,若我們想用一個其他的使用者登入去檢視該使用者具有許可權的目錄時,經常會出現錯誤:(系統發生 1219 錯誤。提供的憑據與已存在的憑據集衝突。)        為什麼會出現這個錯誤呢?因為你的

agooou [QQ:35327864, email: [email p

作者 QQ: 35327864,msn: [email protected],mail: [email protected]   為了能在android平臺上播放全格式的多媒體檔案,我們需要自己做一個多媒體播放器。android自帶的opencore系統

Partial mock local private method or public method in the class and suppress static initial block

public class Calc { static { System.out.println("hahaha"); } public int add(int a, int b) { return interADD(a, b); } private i

agooou [QQ:35327864, email: [email p

微信接入驗證Nodejs版例子程式 介紹 本程式按照微信公眾平臺開發者文件>開始開發>接入指南,進行開發。 微信使用第三方伺服器時要求配置伺服器 登入公眾平臺後,在 基本配置->填寫伺服器配置 中修改資訊時要求填寫的URL能正確

malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug

版本 解決 pointer 系統 解決方法 all list object ued 在集成第三方sdk的時候碰到這個問題, malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from