[Mimedefang] [MIMEDefang] Postfix add headers to outgoing mails

Bill Cole mdlist-20140424 at billmail.scconsult.com
Fri Feb 3 15:30:17 EST 2017


On 2 Feb 2017, at 12:21, M.Roessler at t-systems.com wrote:

> Hi folks,
>
> sorry for my very basic questions about this milter and the necessary 
> configuration to bind to the MTA.
> I'm very new in this field, but i searched the whole week for a 
> solution and look at so much howtos, threads and other stuff. Please 
> help me with this.
>
> My situation at the moment:
>
> My main goal is to add two headers on outbound mails which are send 
> over postfix.

The best place to find Postfix expertise is the Postfix Users list. See 
http://www.postfix.org/lists.html for how to subscribe.

> First i try this with the postfix feature header_checks and the 
> PREPEND action to add the 2 headers which we need.
> It seems that fir this only one rule with PREPEND is allowed in the 
> header_check file, cause of the mechanism postfix go through them.

Yes, header_checks would be the wrong place to do this, if you want this 
to be conditional on the SMTP envelope sender rather than the value of 
the "From" header. To add headers based on the SMTP envelope sender, you 
should use check_sender_access in smtpd_sender_restrictions or 
smtpd_recipient_restrictions. Since you can apply multiple 
check_sender_access maps in restriction lists, you can match the sender 
in 2 distinct access maps and add a header in each one.

However, if you're actually looking to match a header address, I believe 
you can work around the shortcomings of header_checks by also setting 
smtp_header_checks with a pattern file that adds the second header.

These approaches are both a bit clumsy, but they are lighter weight than 
MD. You might get a better Postfix-only answer from the Postfix Users 
list.


> Now my new approach is using a milter on postfix, who i've read should 
> such a tool should be able to add more then one header in a mail.
> I decided for MIMEDefang. I read some HowTo's to bind this extra linux 
> service on my postfix server, hopefully done this correct.
> After that i rewrote the whole /etc/mail/mimedefang-filter, but the 
> headers will never be added.
> I dont find a log file from mimedefang for debugging purposes and also 
> dont see anything in the maillog when i append "-vvv" in postfix 
> master.cf

Don't do that. Postfix verbose logging is overkill. If you're not seeing 
anything in maillog, there's a logging config problem. Both mimedefang 
and postfix use traditional syslog calls with the LOG_MAIL facility, so 
if your logging is set up correctly you should be getting messages from 
both of them in the same file.

> after this line:
> "smtp      inet  n       -       n       
> -       -       smtpd"
>
> (System is CentOS7)

The fact that this is a systemd-based system complicates matters a bit, 
because it is possible to set up CentOS7 (or RHEL7) in a way that fails 
to put anything in any files in /var/log/. Can you see any messages 
using journalctl?

>
> Configuration files:
>
> ########
> #main.cf#
> ################################
> smtpd_milters = inet:127.0.0.1:10025
> ################################

That setting is probably wrong. Usually mimedefang is configured to 
listen on a UNIX-domain socket, so with a pure-defaults mimedefang you'd 
want this:

smtpd_milters = unix:/var/spool/MIMEDefang/mimedefang.sock

Check the -z and -p options that your mimedefang daemon uses to confirm 
to correct that path.




More information about the MIMEDefang mailing list