I've got this problem for a long time and used a lot of tutorials to fix it.
And now i've found the correction !!
I'm posting my config file here and my solution for people who need help like me and also if i've got the same problem an other time.
My solution was :
Add 127.0.0.1 localhost.localdomain localhost
to /etc/hosts and reboot your server.
You can find here all of my postfix config, you can try to copy it. I used two tutorials to configure my postfix server and opendkim server : https://www.linode.com/docs/guides/email-with-postfix-dovecot-and-mysql/ and https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-dkim-with-postfix-on-debian-wheezy
Config file : /etc/default/opendkim
# Command-line options specified here will override the contents of
# /etc/opendkim.conf. See opendkim(8) for a complete list of options.
#DAEMON_OPTS=""
# Change to /var/spool/postfix/var/run/opendkim to use a Unix socket with
# postfix in a chroot:
#RUNDIR=/var/spool/postfix/var/run/opendkim
RUNDIR=/var/run/opendkim
#
# Uncomment to specify an alternate socket
# Note that setting this will override any Socket value in opendkim.conf
# default:
#SOCKET=local:$RUNDIR/opendkim.sock
SOCKET=inet:12301@localhost
# listen on all interfaces on port 54321:
#SOCKET=inet:54321
# listen on loopback on port 12345:
#SOCKET=inet:12345@localhost
# listen on 192.0.2.1 on port 12345:
#SOCKET=inet:[email protected]
USER=opendkim
GROUP=opendkim
PIDFILE=$RUNDIR/$NAME.pid
EXTRAAFTER=
Config file : /etc/opendkim.conf
Syslog yes
UMask 002
Socket inet:12301@localhost
PidFile /var/run/opendkim/opendkim.pid
OversignHeaders From
TrustAnchorFile /usr/share/dns/root.key
Canonicalization relaxed/simple
ExternalIgnoreList refile:/etc/opendkim/TrustedHosts
InternalHosts refile:/etc/opendkim/TrustedHosts
KeyTable refile:/etc/opendkim/KeyTable
SigningTable refile:/etc/opendkim/SigningTable
Mode sv
PidFile /var/run/opendkim/opendkim.pid
SignatureAlgorithm rsa-sha256
UserID opendkim:opendkim
System file : /lib/systemd/system/opendkim.service
Description=OpenDKIM DomainKeys Identified Mail (DKIM) Milter
Documentation=man:opendkim(8) man:opendkim.conf(5) man:opendkim-genkey(8) man:opendkim-genzone(8) man:opend$
After=network.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/opendkim/opendkim.pid
UMask=0002
ExecStart=/usr/sbin/opendkim -P /var/run/opendkim/opendkim.pid -p inet:12301@localhost
Restart=on-failure
ExecReload=/bin/kill -USR1 $MAINPID
[Install]
WantedBy=multi-user.target
I hope i could help you !