An Ejabberd module that registers an offline_message_hook to intercept offline messages and forwards them via HTTP POST requests to a configured URL.
- Registers an
offline_message_hookto intercept offline messages. - Sends HTTP POST requests with form fields:
to,from,body,access_token. - Configurable URL endpoint and access token.
- Configurable HTTP timeout.
- Comprehensive error handling and logging.
- Non-blocking HTTP requests (spawned processes).
- Message Sent: XMPP client sends message to offline user.
- Hook Triggered: Ejabberd triggers
offline_message_hook. - Filtering: Module filters out chat state messages.
- HTTP Forward: Module sends HTTP POST with raw XML stanza.
-
Copy
mod_offline_post.erlto your Ejabberd modules directory (usually/opt/ejabberd/lib/ejabberd-*/ebin/or similar). -
Compile the module:
erlc -I /opt/ejabberd/lib/ejabberd-*/include mod_offline_post.erl -
Add the module to your
ejabberd.ymlconfiguration file:modules: mod_offline_post: post_url: "https://your-server.com/offline-message" access_token: "your-secret-token" timeout: 5000 # Optional, default is 5000ms
-
Restart Ejabberd or reload the configuration:
ejabberdctl restart
| Option | Type | Default | Description |
|---|---|---|---|
post_url |
string | "" |
The URL to send HTTP POST requests to. |
access_token |
string | "" |
Access token to include in the POST data. |
timeout |
integer | 5000 |
HTTP request timeout in milliseconds. |
When an offline message is stored, the module sends a POST request with the following form data:
to: Recipient JID (e.g., "user@example.com").from: Sender JID (e.g., "sender@example.com").body: Message body text.access_token: The configured access token.
Example POST data:
to=user%40example.com&from=sender%40example.com&body=Hello%20World&access_token=your-secret-token
Note: This module was tested with Ejabberd 25.08.
- Check that the module is compiled and in the correct directory.
- Verify the configuration syntax in
ejabberd.yml. - Check Ejabberd logs for compilation errors.
- Verify the
post_urlis configured and reachable. - Check Ejabberd debug logs for HTTP request details.
- Ensure the target server is responding with HTTP 200.
This module is GPLv2-Licensed.