Dynamic Return Path

I am using kumoMTA as relay server, therefore whenever the user sending the mail changes I want my return path to change as well.
For example- A user named ‘patrick’ is sending a mail then the return path should appear as- patrick@example.com
Here example.com refers to my main mail server domain.
If the sending user changes so should the return-path.

For now I am using this configuration in my init.lua to keep it static.
kumo.on(‘smtp_server_message_received’, function(msg)
queue_helper:apply(msg)
local DOMAIN = “mail-10.growl.com
local mail_from_domain = msg:from_header().domain
local signer_relay = kumo.dkim.rsa_sha256_signer {
domain = DOMAIN, – Domain of the relay server
selector = ‘dkim’, – Selector for the DKIM key of the relay server
headers = {‘From’, ‘To’, ‘Content-Type’, ‘Message-Id’, ‘Subject’}, – Headers to be signed
– headers = {‘From’, ‘To’, ‘Subject’, ‘Date’},
key = ‘/opt/kumomta/etc/dkim/growl.com/dkim.key’, – Path to the relay server’s private DKIM key
}

– Sign the message using the relay server’s DKIM signer
if signer_relay then
msg:dkim_sign(signer_relay)
else
kumo.log(‘error’, ‘Failed to initialize DKIM signer for growl.com’)
end
local tenant = msg:get_first_named_header_value ‘X-Tenant’
if tenant then
msg:set_meta(‘tenant’, tenant)
end
msg:set_sender(string.format(‘user1@%s’, DOMAIN))
end)

Also it would be great if I could use my main server domain here instead of relay server domain, that too without affecting the “mailed-by” header of the mail.

Hey there @helpful-emu, thanks for posting. Please read the “Troubleshooting” and “How to Ask for Help” buttons below. If you would like a 1:1 support session from the KumoMTA team, details are at the “Book a Support Session” button below.

Why is the injector not setting a correct MAIL FROM?

Since I want a different mailed-by in the mail headers, I have to explicitly define the return path. Or I get the same mailed-by and signed-by which I do not desire. If I remove this
" msg:set_sender(string.format(‘user1@%s’, DOMAIN))"
then I get the desired return path but then the same mailed-by and signed-by.
Both of these things are intertwined and I want them to work independently of each other.

Why do you want a different mailed-by?

That is the demand of our organization, I am trying to see if KumoMTA can be a valuable fit for that demand.

We don’t set that header.

I am now curious where this “Mailed By” header comes from. Can someone help me understand what adds this to the message?

I have a feeling the “Mailed By” and “Signed By” are just normal headers that you can alter at will using with the header manipulation functions:

look at remove _x_headers and prepend_header

Are you using Google apps to send mail directly through gmail for delivery? Like injecting to smtp.gmail.com?

No, here Gmail is the end recipient nothing more.

My mail chain starts from a main mail server configured for inbound and outbound mailing. It relays outbound mail from KumoMTA but takes inbound mail directly. Further KumoMTA uses a socks proxy and rotates two IPs for final mail delivery.

Still curious what is adding the “Mailed By” header. AFAIK, that is a header added by gmail. Are you saying you want your MTA to alter the mail in a way that makes gmail add a different “mailed-by”?

Yes, that is what I want.

If I set a fixed return path then I can get a desired “mailed-by” but I don’t want the return path to be fixed/static, It should change according to the user sending the mail.

Right but the Gmail “Mailed by” header is literally defined by the return path. You can’t have it both ways.

Can I ask why you want gmail to show a different mailed by that the actual mailed by?

I’m not so sure that is something the gmail postmasters would approve of.

So can I at least make it to change the user of return-path?
Example-
sender is- patrick@showx.com
So I can set a static Return-Path- User1@first.com
So here not the domain but only the user should change ie It should show the return path as this → patrick@first.com
If the sending user is “Alex” then the return path should be → alex@first.com.

That is the requirement of our organization, I am just testing the KumoMTA for it.