How to set an arbitrary sender and name and address in the From field of every email sent via sendmail, ignoring any sender information already set, replacing original.sender <original.sender@host.tld>
by Noreply <noreply@domain.tld>
whatever original.sender
and host.tld
are ?
For context, the mails are sent by a java application using simplejavamail
library, which sets variable sender names and addresses which needs to be dismissed. Changing the application is not an option.
I tried several configurations without success :
- My best try so far is adding the following instructions in
sendmail.mc
:
Actually, this does not rewrite the whole From field, but only the address part :LOCAL_RULE_1 R $* $@ noreply <@domain.tld>
original.sender@host.tld <noreply@domain.tld>
- Any other
R
rule ended in the wanted sender set only in the left side of the address :original.sender@host.tld <Noreply.noreply@domail.tld@host.tld>
H
commands, likeHFrom:noreply@domain.tld
, does nothing.HReply-To:noreply@domain.tld
actually adds the original sender address in the Reply-To header.- I even asked tips to ChatGPT who proposed to use
G
andS
commands alongsideR
, but I think it is confused with something else as it does not work at all and I did not found any documentation about that. - I also tried
MASQUERADE
feature, but it require a list of masqueraded domains, while I need it to work for any domain. Wildcard seems not to be allowed there. - Finally I tried
genericstable
, but as forMASQUERADE
, it seems I can't wildcard domains.