Is there any option to inject some tracking code to message body

file - /opt/kumomta/etc/shaping.json

{ "default": { "replace_base": true, "connection_limit": 3, "max_connection_rate": "100/min", "max_message_rate": "50/min" }, "domain.com": { "connection_limit": 3, "max_message_rate": "10/min", "sources": { "ip-1": { "connection_limit": 5, "max_message_rate": "2/min" } } } }

hi @faithful-ostrich Uploaded all the files. please check

Thanks

so… as mentioned above, “Note that I have not tested that exact code snippet, …”

If you add a diagnostic log filter line to your init, you will see deeper diagnostic logging in your journal.
kumo.set_diagnostic_log_filter 'kumod=debug'
and use this in a separate terminal session to trace the log feed:
journalctl -r -n 10 -u kumomta.service

if you do that you will likely see something like this:

and if you look at that line, you will see I missed a comma in the gsub function

msg_body = msg_body:gsub("<body>" .. my_tracking_link .. "</body>")

should have been

msg_body = msg_body:gsub("<body>", my_tracking_link .. "</body>")

That should eliminate the immediate error, but I have not tested a full end-to-end message send.

How to make sure the “make. reinjector” is working or not?

I have a doubt, the custom lua ‘make. reinjector’ function is not executed

I am fixing many things in this config.
The reinjector is working, but you have no HTTP processor to process it.
also, I am working on a better way to delete the original message

Ok. @faithful-ostrich Iam waiting for your update.

OK, so you don’t actually have to do this with a custom connector and I will explain below. Before I do, I’d like to point out that this represents about $1000 US worth of PS time, so if you are able to process a donation to the cause, it would be greatly appreciated.

Here is proof of life from my own dev/test server:

Dec 20 19:50:22 ctest3.kumomta.com kumod[7756]: NEW PAYLOAD: {"envelope_sender":"mkt@mail.kumomta.com","content":"Received: from ctest3.kumomta.com (127.0.0.1)\r\n  by kumo.domain.com (KumoMTA 127.0.0.1) \r\n  with ESMTP id 02b6f4189f7111eebb62000d3ac431c3 for <tom@kumomta.com>;\r\n  Wed, 20 Dec 2023 19:50:22 +0000\r\nDate: Wed, 20 Dec 2023 19:50:22 +0000\r\nTo: tom@kumomta.com\r\nFrom: mkt@mail.kumomta.com\r\nSubject: test Wed, 20 Dec 2023 19:50:22 +0000\r\nMessage-Id: <20231220195022.007770@ctest3.kumomta.com>\r\nX-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/\r\n\r\nThis is a test <img src=\"http://10.0.0.1/img_chania.jpg\" alt=\"Flowers in Chania\"> </body>\r\n\r\n\r\n","recipients":[{"email":"tom@kumomta.com"}]}
Dec 20 19:50:22 ctest3.kumomta.com kumod[7756]: Processing HTTP injection
Dec 20 19:50:22 ctest3.kumomta.com kumod[7756]: Processing the reinjected message
Dec 20 19:50:22 ctest3.kumomta.com kumod[7756]: successful reinjection, deleting original

You can start by removing the custom connector bits in get_queue_config and effectively move the custom connector code ( with some modification) right into the smtp_server_message_received event. You also need to add an http_message_generated event processor in order to handle the reinjection.

See attached. be sure to read carefully and modify as needed . No NOT just copy and paste.
message.txt (2.29 KB)

Note that this is not meant to be a highly performant solution. YMMV

I’ve just noticed that this line:
msg_body = msg_body:gsub("mailing", my_tracking_link .. " </body>")
should be
msg_body = msg_body:gsub("</body>", my_tracking_link .. " </body>")

That will add the tracking link right before the closing tag.
Best practice would be to place a slightly different one at the top of the page as well.

Okay, @faithful-ostrich . I will check and provide you with an update

Hi @faithful-ostrich Issue has been fixed. Thanks for the support.