What Postfix virtual domain variable should I use in outgoing header creation?
Current server
I'm running a database-driven virtual domain server managed by PostfixAdmin. I want to put statements in the header of all outgoing emails using the Postfix system, not using the responsible web app or client.
We need to produce...
The question is not about a List-Unsubscribe
header, which we already know should look like...
in the email header :
List-Unsubscribe: mailto:[email protected]
How we produce...
We already know to achieve that with a line tailored to outgoing checks /etc/postfix/smtp_header_checks
. So, if we have this line...
main.cf :
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
(or some other setting like some_setting = regexp:/etc/postfix/some_setting
?)
Then, we need in...
/etc/postfix/smtp_header_checks :
/^Content-Type:/i PREPEND List-Unsubscribe: mailto:[email protected]
But, that only works for a specific domain somedomain.tld
; I need a variable that depends on the sending domain.
There are no mydomain =
settings anywhere in main.cf
or any other /etc/postfix/
files; all domains are managed by the virtual domain maps managed by MySQL.
So, this question is about vmail variables any sending header creation, not only List-Unsubscribe:
, as long as it works in creating List-Unsubscribe:
from Postfix.
(Postfix docs aren't clear about usable vmail variables in headers.)
Code with domain variable
This is my best solution: $mydomain
.
/etc/postfix/smtp_header_checks :
/^Content-Type:/i PREPEND List-Unsubscribe: mailto:unsubscribe@$mydomain
When sending from a virtual domain, is $mydomain
the correct way to pass that domain into header or other email content creation sent by Postfix?
(Using Postfix for this is important so that all emails will have this, even those sent from the simple CLI or by third party web apps using PHP via MSMTP, et cetera. We already know how to add it via server lang header.)
Postfix
does not provide a built-in variable that directly corresponds to the sender's domain insmtp_header_checks
, but we can use regex arguments fromheader_checks
combined withsmtp_header_checks
to do the same thing.First we use this custom header in
/etc/postfix/header_checks : add this
Then prepend the
List-Unsubscribe
header using the customX-Sender-Domain
in/etc/postfix/smtp_header_checks : we have
Then make sure in
main.cf : we have
Then we reload, and it should work.
$
sudo postfix reload