Skip to content

MichaelHorta/AmazonSESNotifications

Repository files navigation

Notifications For Amazon SES (.NET)

Nuget badge

Nuget

You can find nuget package with name AmazonSESNotifications

Example of content for notification variable

Obtained from Developer Guide of Amazon Simple Email Service

{
  "notificationType": "Delivery",
  "mail": {
    "timestamp": "2018-10-08T14:05:45 +0000",
    "messageId": "000001378603177f-7a5433e7-8edb-42ae-af10-f0181f34d6ee-000000",
    "source": "[email protected]",
    "sourceArn": "arn:aws:ses:us-west-2:888888888888:identity/example.com",
    "sourceIp": "127.0.3.0",
    "sendingAccountId": "123456789012",
    "destination": [
      "[email protected]"
    ],
    "headersTruncated": false,
    "headers": [
      {
        "name": "From",
        "value": "\"Sender Name\" <[email protected]>"
      },
      {
        "name": "To",
        "value": "\"Recipient Name\" <[email protected]>"
      },
      {
        "name": "Message-ID",
        "value": "custom-message-ID"
      },
      {
        "name": "Subject",
        "value": "Hello"
      },
      {
        "name": "Content-Type",
        "value": "text/plain; charset=\"UTF-8\""
      },
      {
        "name": "Content-Transfer-Encoding",
        "value": "base64"
      },
      {
        "name": "Date",
        "value": "Mon, 08 Oct 2018 14:05:45 +0000"
      }
    ],
    "commonHeaders": {
      "from": [
        "Sender Name <[email protected]>"
      ],
      "date": "Mon, 08 Oct 2018 14:05:45 +0000",
      "to": [
        "Recipient Name <[email protected]>"
      ],
      "messageId": " custom-message-ID",
      "subject": "Message sent using Amazon SES"
    }
  },
  "delivery": {
    "timestamp": "2014-05-28T22:41:01.184Z",
    "processingTimeMillis": 546,
    "recipients": [
      "[email protected]"
    ],
    "smtpResponse": "250 ok:  Message 64111812 accepted",
    "reportingMTA": "a8-70.smtp-out.amazonses.com",
    "remoteMtaIp": "127.0.2.0"
  }
}

Examples

Parsing unidentified notification

AmazonSESNotification amazonSESNotification = AmazonSESNotification.Parse(notification);

Trying to parse unidentified notification

AmazonSESNotification amazonSESNotification = null;
bool parsed = AmazonSESNotification.TryParse(notification, out amazonSESNotification);

Working withAmazonSESBounceNotification notification

AmazonSESBounceNotification amazonSESBounceNotification = new AmazonSESBounceNotification(notification);
AmazonSESBounceNotification amazonSESBounceNotification = AmazonSESBounceNotification.Parse(notification);
AmazonSESNotification amazonSESNotification = null;
bool parsed = AmazonSESBounceNotification.TryParse(notification, out amazonSESNotification);
AmazonSESBounceNotification amazonSESBounceNotification = amazonSESNotification as AmazonSESBounceNotification;

Working withAmazonSESComplaintNotification notification

AmazonSESComplaintNotification amazonSESComplaintNotification = new AmazonSESComplaintNotification(notification);
AmazonSESComplaintNotification amazonSESComplaintNotification = AmazonSESComplaintNotification.Parse(notification);
AmazonSESNotification amazonSESNotification = null;
bool parsed = AmazonSESComplaintNotification.TryParse(notification, out amazonSESNotification);
AmazonSESComplaintNotification amazonSESComplaintNotification = amazonSESNotification as AmazonSESComplaintNotification;

Working withAmazonSESDeliveryNotification notification

AmazonSESDeliveryNotification amazonSESDeliveryNotification = new AmazonSESDeliveryNotification(notification);
AmazonSESDeliveryNotification amazonSESDeliveryNotification = AmazonSESDeliveryNotification.Parse(notification);
AmazonSESNotification amazonSESNotification = null;
bool parsed = AmazonSESDeliveryNotification.TryParse(notification, out amazonSESNotification);
AmazonSESDeliveryNotification amazonSESDeliveryNotification = amazonSESNotification as AmazonSESDeliveryNotification;

Unit tests

After build the project AmazonSESNotificationsTests, run unit tests with the tool console runner installed by the package NUnit.ConsoleRunner

$ packages\NUnit.ConsoleRunner.3.9.0\tools\nunit3-console.exe NotificationForAmazonSESTests\bin\Debug\AmazonSESNotificationsTests.dll

Releases

No releases published

Packages

No packages published

Languages