Skip to content

Amazon SQS (Message Queuing Service) golang convert and parse to json structs of notification-contents of the Amazon SNS message of the Amazon SES service (Amazon Simple Email Service)

License

Notifications You must be signed in to change notification settings

web-ridge/sns_ses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sns_ses

Amazon SQS (Message Queuing Service) golang convert and parse to json structs of notification-contents of the Amazon SNS message of the Amazon SES service (Amazon Simple Email Service) amazon/notification-contents

Bindings for

  • Received Mail
  • Bounce
  • s3 Receipt
  • Complaint
  • Delivery

Example

func handlePubSubMailMessage(ctx context.Context, msg *sqs.Message) error {
	body := &sns_ses.Body{}
	err := json.Unmarshal([]byte(*msg.Body), &body)
	if err != nil {
		return err
	}

	message := &sns_ses.Message{}
	err = json.Unmarshal([]byte(body.Message), &message)
	if err != nil {
		return err
	}
  	switch message.NotificationType {
	case sns_ses.NotificationTypeBounce:
	case sns_ses.NotificationTypeComplaint:
	case sns_ses.NotificationTypeDelivery:
	case sns_ses.NotificationTypeReceived:
		messageContent, err := incomingMailS3.GetObject(&s3.GetObjectInput{
			Bucket: aws.String(message.Receipt.Action.BucketName),
			Key:    aws.String(message.Receipt.Action.ObjectKey),
		})

	}
}

Extra

If you want to strip signature and quoted-replies from the received message you could use another library we made: web-ridge/email-reply-parser

About

Amazon SQS (Message Queuing Service) golang convert and parse to json structs of notification-contents of the Amazon SNS message of the Amazon SES service (Amazon Simple Email Service)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages