Email Alert sending separate emails for different messages

Using the Graylog version: 3.3.2

I am using the below template for Graylog alerts and have not been receiving emails as expected.

--- [Event Definition] ---------------------------
Title:       ${event_definition_title}
Description: ${event_definition_description}
Type:        ${event_definition_type}
--- [Messages] -----------------------------------
${if backlog} ${foreach backlog message}
Response Code: ${message.fields.response_code} | HTTP_REFERRER: ${message.fields.http_referrer}
${end}${else}No Backlog${end}
--- [Event] --------------------------------------
Timestamp:            ${event.timestamp}
Message:              ${event.message}
Source:               ${event.source}
--------------------------------------------------

While receiving email, I’m getting separate email for every message in backlog as below:

First Email:

--- [Event Definition] ---------------------------
Title:       http referrer
Description: Http referrer with status code !=200
Type:        aggregation-v1
--- [Messages] -----------------------------------

Response Code: 404 | HTTP_REFERRER: https://xxxx.xxx.xxxx/xxx

--- [Event] --------------------------------------
Timestamp:            2020-07-28T08:31:48.859Z
Message:              http referrer
Source:               e9ac8be01bcb
--------------------------------------------------

Second Email:

--- [Event Definition] ---------------------------
Title:       http referrer
Description: Http referrer with status code !=200
Type:        aggregation-v1
--- [Messages] -----------------------------------

Response Code: 502 | HTTP_REFERRER: https://xxxxx.xxxx/xxxx

--- [Event] --------------------------------------
Timestamp:            2020-07-28T09:01:05.465Z
Message:              http referrer
Source:               e9ac8be01bcb
--------------------------------------------------

Third Email:

--- [Event Definition] ---------------------------
Title:       http referrer
Description: Http referrer with status code !=200
Type:        aggregation-v1
--- [Messages] -----------------------------------

Response Code: 404 | HTTP_REFERRER: https://xxx.xxx.xxx.xxx/xxx

--- [Event] --------------------------------------
Timestamp:            2020-07-28T09:41:17.301Z
Message:              http referrer
Source:               e9ac8be01bcb
--------------------------------------------------

and so on.

I have been getting thousands of emails like this below:

Screenshot

I want to get all the backlog messages in a single email body, like below:

--- [Event Definition] ---------------------------
Title:       http referrer
Description: Http referrer with status code !=200
Type:        aggregation-v1
--- [Messages] -----------------------------------

Response Code: 404 | HTTP_REFERRER: https://xxxx.xxx.xxxx/xxx
Response Code: 502 | HTTP_REFERRER: https://xxxxx.xxxx/xxxx
Response Code: 404 | HTTP_REFERRER: https://xxx.xxx.xxx.xxx/xxx

--- [Event] --------------------------------------
Timestamp:            2020-07-28T08:31:48.859Z
Message:              http referrer
Source:               e9ac8be01bcb
--------------------------------------------------

Kindly guide me with the solution. Thanks!

how did you configure the events and alerst?

Took the screenshot of Summary:


I hope it helps in understanding the problem.

Hello @jan,
Please help anything I can try to make this work?

Thanks!