From 69a4d3126bccecd40e18b19853d8fd8ff5e78e23 Mon Sep 17 00:00:00 2001 From: Doug Koerich Date: Tue, 27 Jan 2026 11:06:46 -0300 Subject: [PATCH] TASK-115992: New attempted_ip info in ec_message (for logging) Signed-off-by: Doug Koerich --- .../momentum/3/3-api/structs-ec-message.md | 12 +++++- content/momentum/4/4-lua-summary-table.md | 1 + content/momentum/4/lua/index.md | 1 + .../momentum/4/lua/ref-msg-attempted-ip.md | 37 +++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 content/momentum/4/lua/ref-msg-attempted-ip.md diff --git a/content/momentum/3/3-api/structs-ec-message.md b/content/momentum/3/3-api/structs-ec-message.md index 41c9db8ed..c16984987 100644 --- a/content/momentum/3/3-api/structs-ec-message.md +++ b/content/momentum/3/3-api/structs-ec-message.md @@ -118,6 +118,16 @@ struct _ec_message { /** @internal */ const char *pathway; ec_message_resource_t *resources; + + /** @since 4.3.2 */ + /* set through ec_message_set_routing_domain, then + used in ec_message_get_routing_domain. + This field will not be written to spool */ + string _routing_domain; + + /** @since 5.2 */ + /* TASK-115992: make sure an attempted IP can be logged in case of temp/perm failures */ + address attempted_ip; }; ``` @@ -125,4 +135,4 @@ To use this struct, include the file `ec_message.h`. ### See Also -[*Message Functions*](/momentum/3/3-api/ec-message) , and [“ec_message_part”](/momentum/3/3-api/structs-ec-message-part). \ No newline at end of file +[*Message Functions*](/momentum/3/3-api/ec-message) , and [“ec_message_part”](/momentum/3/3-api/structs-ec-message-part). diff --git a/content/momentum/4/4-lua-summary-table.md b/content/momentum/4/4-lua-summary-table.md index 366e07deb..ff3fb1d70 100644 --- a/content/momentum/4/4-lua-summary-table.md +++ b/content/momentum/4/4-lua-summary-table.md @@ -28,6 +28,7 @@ This section contains tables of Lua functions. Click the function name for detai | [msg.batch_id](/momentum/4/lua/ref-msg-batch-id) – Returns the human-readable ec_message.batch_id |   | msys.extended.message | 4.0 | data, data_spool, data_spool_each_rcpt, set_binding | | [msg.conn_id](/momentum/4/lua/ref-msg-conn-id) – Returns the human-readable ec_message.conn_id |   | msys.extended.message | 4.0 | data, data_spool, data_spool_each_rcpt, set_binding | | [msg.id](/momentum/4/lua/ref-msg-id) – Returns the human-readable ec_message.id |   | msys.extended.message | 4.0 | data, data_spool, data_spool_each_rcpt, set_binding | +| [msg:attempted_ip](/momentum/4/lua/ref-attempted-ip) – Gets the IP address (if any) that was attempted for a failed outbound connection | | msys.extended.message | 5.2 | core_log_delivery_v1, core_log_transient_failure_v1, core_log_permanent_failure_v1 | | [msg:binding](/momentum/4/lua/ref-msg-binding) – Sets the binding to the named binding, if one is provided | [value] | msys.extended.message | 4.0 | set_binding | | [msg:binding_group](/momentum/4/lua/ref-msg-binding-group) – Sets the binding_group to the named binding, if one is provided | [value] | msys.extended.message | 4.0 | set_binding | | [msg:body](/momentum/4/lua/ref-msg-body) – Set or get the message body (minus headers) | [...] | msys.extended.message | 4.0 | data, data_spool, data_spool_each_rcpt, set_binding | diff --git a/content/momentum/4/lua/index.md b/content/momentum/4/lua/index.md index 342fd1a7f..5a6ea3ccc 100644 --- a/content/momentum/4/lua/index.md +++ b/content/momentum/4/lua/index.md @@ -87,6 +87,7 @@ description: "This section details all Lua functions Functions are ordered alpha | [msg.conn_id](/momentum/4/lua/ref-msg-conn-id) | Return the human-readable ec_message.conn_id | | [msg.id](/momentum/4/lua/ref-msg-id) | Return the human-readable ec_message.id | | [msg:address_header](/momentum/4/lua/ref-msg-address-header) | Returns address components as an array | +| [msg:attempted_ip](/momentum/4/lua/ref-msg-attempted-ip) | Gets the attempted IP address for a failed outbound connection | | [msg:binding](/momentum/4/lua/ref-msg-binding) | Set or get the message binding | | [msg:binding_group](/momentum/4/lua/ref-msg-binding-group) | Sets the binding_group to the named binding, if one is provided. | | [msg:body](/momentum/4/lua/ref-msg-body) | Set the message body (minus headers) if provided | diff --git a/content/momentum/4/lua/ref-msg-attempted-ip.md b/content/momentum/4/lua/ref-msg-attempted-ip.md new file mode 100644 index 000000000..0a932d0a7 --- /dev/null +++ b/content/momentum/4/lua/ref-msg-attempted-ip.md @@ -0,0 +1,37 @@ +--- +lastUpdated: "01/31/2026" +title: "msg:attempted_ip" +description: "msg attempted_ip Gets the IP address (if any) that was attempted for a failed outbound connection" +--- + + +## Name + +msg:attempted_ip — Gets the IP address (if any) that was attempted for a failed outbound connection. + +> This function was introduced in Momentum 5.2. + + +## Synopsis + +`msg:attempted_ip()` + + +## Description + +For successful mail deliveries, connection details are available through the connection handle (`conn_handle`) in the message object (`ec_message`). However, when a connection fails, the handle is null. The `attempted_ip` field in the message object can be checked for the IP address that Momentum attempted to connect to. This is useful for logging connection attempts and troubleshooting delivery issues. The `attempted_ip()` function returns `nil` if the IP address is unknown. + + + +``` +require("msys.core") +require("msys.extended.message") + +local mod = {} + +function mod:core_log_transient_failure_v1(msg, dr, now, note, note_len) + print(tostring(msg.id) .. ": failed to connect to mail server using the IP address " .. tostring(msg:attempted_ip())) +end + +msys.registerModule("example", mod) +```