function engagements_handle_incoming_aws_email

7.x engagements.module engagements_handle_incoming_aws_email()

File

modules/engagements/engagements.module, line 161
This is the primary module file for the engagements module.

Code

function engagements_handle_incoming_aws_email() {

  $sns = @json_decode(@file_get_contents("php://input"), TRUE);

  if (!$sns) {
    die();
  }




  $source_arn = "";
  $to_email = "";
  $event_type = "";

  if (isset($sns ['bounce']) && $sns ['bounce']['bounceType'] == 'Permanent') {
    $event_type = "bounce";
    $to_email = $sns ['mail']['destination'][0];
    $source_arn = $sns ['mail']['sourceArn'];
  } // sns permanent bounce has occured.

  if (isset($sns ['complaint']) && isset($sns ['complaint']['complainedRecipients'])) {
    $event_type = "complaint";
    $to_email = $sns ['mail']['destination'][0];
    $source_arn = $sns ['mail']['sourceArn'];
  } // sns complaint (spam mark by recipient) has occured.


  // TODO: verify by looking at the source_arn and make sure its mine.  Not the most fool-proof way to do it, but eh, who cares.




  watchdog('debug_aws', "Type: $event_type<br>to_email $to_email<br>srcarn: $source_arn<br>
                          <pre>" . print_r($sns, TRUE) . '</pre>');




}