Route events to Direct Mail
Use event rules to filter and route events to Direct Mail. This topic uses a custom event to demonstrate the prerequisites, procedure, and how to verify the result.
Prerequisites
Step 1: Add a custom event source
- Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
- In the top navigation bar, select a region. On the Event Buses page, click the name of your target custom event bus.
- In the left-side navigation pane, click Event Sources, and then click Add Event Source.
-
In the Add Custom Event Source panel, enter a Name and Description. For Event Provider, select Custom Application, and then click OK.
Step 2: Create an event rule
The target service and the event rule must be in the same region.
- Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
- In the top navigation bar, select a region. On the Event Buses page, click the name of the target event bus.
- In the left-side navigation pane, click Event Rules, and then click Create Rule.
-
On the Create Rule page, complete the following steps.
-
In the Configure Basic Info step, enter a name for the rule in the Name field and a description in the Description field. Then, click Next.
-
In the Configure Event Pattern step, select Custom Event Sources for Event Source Type, select the custom event source that you added in Step 1 for Event Sources, and enter an event pattern in the Pattern Content code editor. Then, click Next.
For more information, see event patterns.
-
In the Configure Targets step, configure the event target, and then click Create.
NoteYou can add up to five event targets to a single event rule.
-
Service Type: Select Email.
-
Subject: Enter a subject for the email.
-
Sender Address: Enter the sender address that is configured in Direct Mail.
-
Address Type: Select Random Account or Sender Address.
-
Return Address: Select Yes or No.
-
Recipient: Select Fixed Value or Template.
-
The following example shows a fixed value:
alice@example.com -
The following example shows a template:
$.data.addr
NoteYou can enter up to 100 email addresses, separated by commas.
-
-
HTML Body: Select Yes or No.
-
Yes: The body is in HTML format.
-
No: The body is in plain text format.
-
-
Body: By default, this is set to Body. You can use custom variables and a template to format the event output.
Variable example:
{ "source":"$.source", "type":"$.type" }Template example:
An error was sent from ${source},caused by ${type}.For more information, see event transformation.
-
-
Step 3: Publish an event
- Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
- In the top navigation bar, select a region.
-
On the Event Buses page, find the target event bus and click Publish Event in the Operations column.
NoteOnly custom event buses support publishing events from the console.
-
In the Publish Event to Custom Event Bus {name} panel, select the custom event source that you created from the Custom Event Source drop-down list, enter the event body in the Event Body code editor, and then click OK.
For more information about the parameters in an event, see Event overview.
Verify the result
You can view delivery reports in the Direct Mail console.
-
Log on to the Direct Mail console.
-
In the top navigation bar, select a region.
-
In the left-side navigation pane, choose .
-
On the Delivery Reports page, specify Email Tag, Sender Address, Start Time, and End Time, and then click Query.
You can view statistics for the last seven days, including the total number of emails sent, successful deliveries, failed deliveries, invalid addresses, success rate, and invalid address rate.
Figure 1. Example of an email delivery trend chart
