I am signing all the emails for all domains that goes through my postfix MTA, but I need to custom sign some emails for some domain from my application, is it possible to stop opendkim from signing emails if it already has signature?
There might be a way with OpenDKIM but you can at least do it in postfix with
/^DKIM-Signature: / FILTER smtp:127.0.0.1:10025
/etc/postfix/master.cf make two changes. First duplicate the SMTP listener so that it also listens on port 10025 but exclude the OpenDKIM milter. To the listen port, add the
-o header_checks=regexp:/etc/postfix/header_checks option, e.g.
10025 inet n - n - - smtpd smtp inet n - n - - smtpd -o header_checks=regexp:/etc/postfix/header_checks -o smtpd_milters=inet:localhost:8891
Obviously change this to the submission port (587) and preserve any other flags, as appropriate to your situation.