How to correctly configure postfix and opendkim and let receiving server know all details mailed-by signed-by?
First of all, please remove these values (they aren't needed if you use KeyTable):
Domain example1.com
KeyFile /etc/opendkim/keys/example1_com/selc
Selector selc
Domain example2.com
KeyFile /etc/opendkim/keys/example2_com/selc
Selector selc
Setup your KeyTable like that:
mykey1 example1.com:recordname1:/path/to/domain.key
mykey2 example2.com:recordname2:/path/to/domain.key
Setup your SigningTable like that (note wildcard matching and mykey1 and mykey2 from KeyTable):
*@example1.com mykey1
*@example2.com mykey2
And finally change your opendkim.conf to include SigningTable via refile: prefix (regular expressions support):
SigningTable refile:/etc/opendkim/SigningTable
And domain record for reference (note recordname1 and recordname2 from KeyTable):
recordname1._domainkey IN TXT "v=DKIM1; g=*; k=rsa; p=..."
recordname2._domainkey IN TXT "v=DKIM1; g=*; k=rsa; p=..."
Additionally, please, check if you have your node hostname (from which you are sending mail) in InternalHosts file:
server1.example1.com
server2.example2.com
mail.example1.com
mail.example2.com
Again, you can use refile: prefix to be able to add something like:
*.example1.com
*.example2.com
if you have multiple hosts and do not want to include all of them by hand. If you accept only local mail, you should add localhost here.
You should check log file for DKIM notices about skipping signing if your host is missing in the InternalHosts file.
Example of opendkim.conf:
# Set these values (Syslog, SyslogSuccess, LogWhy) for debugging and check syslog for details
Syslog yes
SyslogSuccess yes
LogWhy yes
UMask 002
UserID opendkim:opendkim
KeyTable /etc/opendkim/KeyTable
SigningTable refile:/etc/mail/SigningTable
InternalHosts refile:/etc/mail/hosts