2017 © Pedro Peláez
 

library antibounce

Anti bounce plugin is able to prevent the email that bounceed from being sent it again once.

image

uluru/antibounce

Anti bounce plugin is able to prevent the email that bounceed from being sent it again once.

  • Thursday, March 17, 2016
  • by uluru-dev
  • Repository
  • 7 Watchers
  • 0 Stars
  • 431 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

anti_bounce

「SES - SNS - アプリケーション」の連携でバウンス情報を取得し、アプリケーション側で対象のメールアドレスに対して処理を行うためのプラグインになります。, (*1)

注意) アプリケーションサーバにIP制限などが掛かっていると、SNSから通知が来ませんので、SNSの通信制限を開放してやる必要があります。, (*2)

SES, SNS のゾーンは US-EAST-1 (バージニア北部), (*3)

IP一覧: https://forums.aws.amazon.com/ann.jspa?annID=2347, (*4)

1. プログラム側の準備

1-1. bounce_logs テーブルを用意する

バウンス履歴を保存するテーブル(bounce_logs)を作成してください。 (Model の作成は必要ありません), (*5)

Field Type Null Key Default Extra Comment
id int(11) NO PRI NULL auto_increment
***_id int(11) NO MUL NULL settings.email に応じて設定
message text NO NULL
created datetime NO NULL
modified datetime NO NULL

1-2. composer.json で本プラグインと aws-php-sns-message-validator をインストール

"repositories": [{
  "type": "package",
  "package": {
      "name": "plugins/anti_bounce",
      "version": "1.0",
      "type": "cakephp-plugin",
      "require": {
          "composer/installers": "*"
      },
      "source": {
          "url": "git@github.com:uluru/anti_bounce.git",
          "type": "git",
          "reference": "master"
      }
  }
}]


"extra": {
    "installer-paths": {
        "app/plugins/anti_bounce": ["plugins/anti_bounce"]
    }
}


"require": {
    "plugins/anti_bounce": "1.0",
    "aws/aws-php-sns-message-validator": "1.1"
}

1-3. 設定ファイルの更新

routes.php, (*6)

Router::connect(
    '/anti_bounce/receive',
    array(
        'plugin' => 'AntiBounce',
        'controller' => 'AntiBounce',
        'action' => 'receive'
    )
);

bootstrap.php, (*7)

Configure::write(
    'AntiBounce',
    array(
        'topic' => '*****',
        'mail' => '*****',
        'settings' => array(
            'stopSending' => false, // true = stop mail sending, false = just write log
            'email' => array(
                'model' => 'User',
                'key' => 'id',
                'mailField' => 'mail_address',
            ), // メールアドレスのレコードを指定する
            'updateFields' => array(
                array(
                    'model' => 'User',
                    'key' => 'id',
                    'fields' => array(
                        'send' => 0,
                        'active' => 0,
                    )
                )
            ) // stopSending = true の場合に更新するレコードの設定
        )
    )
);

2. SESにメールアドレスを登録

「Verify a New Email Address」→「Verify This Email Address」→送信されてきたメールアドレスのリンク押下し、メールアドレスを有効化, (*8)

有効化したメールアドレスを bootstrap.php の mail 項目へ記載する。, (*9)

3. SESコンソールでSNSトピックを作成

  1. 「Email Addresses」→ 2で登録したメールアドレスをクリック
  2. 「Notifications」タブの「Edit Notification Configuration」をクリック
  3. 「Edit Notification Configuration」をクリック
  4. 「Topic Name」「Display Name」を適宜入力
  5. 「Create Topic」すると Bounce 項目のプルダウンに作成したTopicが表示されるのでそれを選択します。

4. SNSのTopicを有効化

3で作成したSNSトピックは、SNSのバージニア北部(ゾーン: US-EAST)に作成されています。, (*10)

Topic ARN 項目を bootstrap.php の topic 項目へ記載する。, (*11)

ARNリンクをクリック→「Create Subscription」をクリック, (*12)

通信プロトコル : https, (*13)

Endpoint : https://*****.****/anti_bounce/receive, (*14)

とする。 数秒後コンソールをリロードすると, (*15)

Subscription ID = PendingConfirmation
↓
Subscription ID = arn:aws:sns:us-east-1:\*\*\*\*

となり Endpoint への通信確認が取れます。, (*16)

5. bounceメールをテスト送信

これで SES - SNS - アプリケーション 連携の準備が整ったので、SESにてbounceメールのテスト送信を行います。, (*17)

テストメール送信方法 * http://docs.aws.amazon.com/ja_jp/ses/latest/DeveloperGuide/getting-started-send-from-console.html * https://docs.aws.amazon.com/ja_jp/ses/latest/DeveloperGuide/mailbox-simulator.html, (*18)

そうすると、4で設定したEndpoint宛にバウンスしたメール情報が通知されるようになります。, (*19)

以降はアプリケーション側から送信されるメールアドレス(バウンスしたメールアドレス)に紐付くレコードがあった場合 bootstrap.php で設定したモデルが更新されます。, (*20)

The Versions

17/03 2016

dev-master

9999999-dev https://www.uluru.biz

Anti bounce plugin is able to prevent the email that bounceed from being sent it again once.

  Sources   Download

MIT

The Requires

 

by Takayuki Maehira

cakephp aws sns ses

17/03 2016

dev-CakePHP3.x

dev-CakePHP3.x https://www.uluru.biz

Anti bounce plugin is able to prevent the email that bounceed from being sent it again once.

  Sources   Download

MIT

The Requires

 

by Takayuki Maehira

cakephp aws sns ses

30/09 2015

1.0

1.0.0.0 https://www.uluru.biz

Anti bounce plugin is able to prevent the email that bounceed from being sent it again once.

  Sources   Download

MIT

The Requires

 

by Takayuki Maehira

cakephp aws sns ses