# Queue mail DNS changes for downstream consumers

Deliver an observed DNS change as one JSON message so a worker can process it asynchronously and retry independently.

[Use template](https://dashboard.fasthook.io/workflow/new?templateKey=cloudflare-dns-mail-events-to-amazon-sqs&templateName=Queue+mail+DNS+changes+for+downstream+consumers)

**Required accounts**

- Cloudflare DNS
- Amazon SQS

## Queue mail DNS changes for downstream consumers

### 1. Trigger · Mail routing or authentication changed

**Cloudflare DNS**. Start when the observed MX, SPF or DMARC records differ from the previous check. The first check saves a baseline.

### 2. Action · Enqueue the DNS change

**Amazon SQS**. Delivers a message to the specified queue. A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed. For more information, see the W3C specification for characters. \#x9 \| \#xA \| \#xD \| \#x20 to \#xD7FF \| \#xE000 to \#xFFFD \| \#x10000 to \#x10FFFF If a message contains characters outside the allowed set, Amazon SQS rejects the message and returns an InvalidMessageContents error. Ensure that your message body includes only valid characters to avoid this exception.

## Set up your workflow

1. **Choose a standard queue** Connect Amazon SQS with permission to send messages to the selected standard queue. Paste or select its queue URL.
2. **Watch a mail domain** Select the zone and domain in the Cloudflare trigger. Allow the first poll to finish before changing an MX, SPF or DMARC record.
3. **Validate the consumer contract** Read a test message and parse its body as JSON. It contains change\_id, domain, observed\_at, previous and current. Have consumers deduplicate on change\_id because standard queues may redeliver.

## Related integrations

- [Cloudflare DNS integrations](https://www.fasthook.io/apps/cloudflare-dns/integrations)
- [Amazon SQS integrations](https://www.fasthook.io/apps/amazon-sqs/integrations)
