Postfix and clamsmtp smtp_bind_address
In order to send emails through Postfix outside of localhost, I had to set the Postfix smtp_bind_address to the server's private IP. The setting was required for both an Ubuntu 17.04 and Centos7 server.
Clamsmtp Postfix settings likewise had to be set to the smtp_bind_address, as 127.0.0.1 created 'transport unavailable' errors.
The comments by Jeff Roberson were applicable as well.
Ubuntu settings as follows:
clamsmtp.conf was set with clamav as the user; and owner permissions were changed from clamsmtp to clamav for the following directories/files:
ClamAddress: /var/run/clamav/clamd.ctl
TempDirectory: /var/spool/clamsmtp
PidFile: /var/run/clamsmtp/clamsmtpd.pid
(I read elsewhere that ownership permissions could also be resolved by adding user clamsmtp to the clamav group.)
Local Socket files had to match:
clamsmtp.conf - ClamAddress: /var/run/clamav/clamd.ctl
clamd.conf - LocalSocket /run/clamav/clamd.ctl
/etc/clamsmtp.conf
OutAddress: 10026
Listen: 0.0.0.0:10025
ClamAddress: /var/run/clamav/clamd.ctl
TempDirectory: /var/spool/clamsmtp
PidFile: /var/run/clamsmtp/clamsmtpd.pid
(symlink in Ubuntu, PidFile could be changed to /run/clamsmtp/clamsmtpd.pid)
User: clamav
/etc/clamav/clamd.conf:
LocalSocket /var/run/clamav/clamd.ctl
(symlink in Ubuntu, LocalSocket could be changed to /run/clamsmtp/clamsmtpd.pid)
FixStaleSocket true
LocalSocketGroup clamav
User clamav
Postfix
main.cf:
(Network Setting with server's private IP)
smtp_bind_address=xxx.xxx.x.xx
(clamsmtp Settings with server's private IP)
content_filter = scan:xxx.xxx.x.xx:10025
receive_override_options = no_address_mappings
master.cf:
(clamsmtp Settings with server's private IP)
scan unix - - n - 16 smtp
-o smtp_send_xforward_command=yes
# For injecting mail back into postfix from the filter
xxx.xxx.x.xx:10026 inet n - n - 16 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks_style=host
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
Start or Restart postfix, clamav-daemon (clamd), clamsmtp as root:
systemctl restart postfix clamav-daemon clamsmtp
Check status, all should be Active:
systemctl status postfix clamav-daemon clamsmtp