# mod\_email\_relay

Source: https://zotonic.com/docs/2087/mod_email_relay

URI: https://zotonic.com/id/2087

Language: en



This module supports relaying email between Zotonic servers.

With `is_email_relay` enabled, this server forwards outbound email payloads to another Zotonic relay server at `email_relay_url`. The two servers authenticate requests using shared secrets: `email_relay_send_secret` for sending relay requests and `email_relay_receive_secret` for receiving relay requests. The relay server sends delivery status updates back through webhook reports.

The optional `is_user_relay` mode relays inbound messages for local `username@hostname` addresses directly to user mailbox addresses from identity/resource data. This user-relay mode is experimental and should not be relied on for production mail flow.

Accepted Events
---------------

This module handles the following notifier callbacks:

- `observe_email_bounced`: If the bounced email is a relayed email, then forward a delivery report using `z_db:q`.
- `observe_email_failed`: If the failed email is a relayed email, then forward a delivery report using `z_string:sanitize_utf8`.
- `observe_email_received`: Check if the recipient is a known user, if so redirect the received e-mail as-is to that user using `m_config:get_boolean`.
- `observe_email_send_encoded`: Relay an email via another Zotonic server using `m_config:get_boolean`.
- `observe_email_sent`: If the sent email is a relayed email, then forward a delivery report using `z_db:q`.
- `observe_email_status`: Forward blocking/unblocking of email addresses to the relaying Zotonic server using `m_config:get_boolean`.
- `observe_tick_24h`: Run daily cleanup of relay queues and stale relay status records.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2087?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2087?language=en>)
