FreeBSD 10 Exim Dovecot RoundCube Spamassasin
FreeBSD 10.0. domain.com is the external domain name. In DNS: A - mx.domain.com; MX - mx.domain.com; A - mail.domain.com for user client configuration; CNAME - webmail.domain.com for user web access.
localhost.localdomain is the host name. In DNS: CNAME mail.localdomain.
Use the configuration from the previously working Exim 4.73 installation.
Disable Sendmail
In /etc/rc.conf:
# DISABLE sendmail
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
Edit /etc/mail/mailer.conf:
sendmail /usr/local/sbin/exim
send-mail /usr/local/sbin/exim
mailq /usr/local/sbin/exim -bp
newaliases /usr/local/sbin/exim -bi
hoststat /usr/local/sbin/exim
purgestat /usr/local/sbin/exim
The server must have: mysql56-server php55 php55-extensions apache24 phpmyadmin
Imported the exim database into MySQL from a backup. Copied config.inc.php for Postfix. Postfix Admin started successfully.
Exim
Select SPF in the configuration. Restored configuration files from backup. It worked. Fixed this in routers.conf:
#-----------------------------------------
# Email aliases
#-----------------------------------------
email_aliases:
driver = redirect
allow_fail
allow_defer
data = ${lookup mysql{SELECT `goto` FROM `alias` WHERE \
`address`='${quote_mysql:$local_part@$domain}' OR \
`address`='${quote_mysql:@$domain}'} \
}
#-----------------------------------------
# Aliases for system users
#-----------------------------------------
system_aliases:
driver = redirect
data = ${lookup{$local_part}lsearch{/etc/aliases}}
Roundcube
Edit /usr/local/etc/apache24/httpd/conf:
Add a configuration file to Apache:
root@v09:/usr/local # cat /usr/local/etc/apache24/Includes/roundcube.conf
Options None
AllowOverride Limit
Require all granted
Restart Apache. Open http://webmail and receive this error:
Open http://webmail/installer/. Use the installer interface to complete setup. Added to config.inc.php:
Install /usr/ports/sysutils/php55-fileinfo. IMAP does not respond because Dovecot is not installed yet.
When sending mail through the web interface, Return-path was set to [email protected]. Fix it in /usr/local/www/roundcube/config/defaults.inc.php:
Dovecot 2.2.13
cd /usr/ports/mail/dovecot2/
make install clean
# Select MySQL; disable PGSQL.
echo 'dovecot_enable="YES"' >> /etc/rc.conf
Copy the contents of /usr/local/etc/dovecot/ from the backup. Start it:
root@v09:/usr/ports/mail/dovecot2 # /usr/local/etc/rc.d/dovecot start
Starting dovecot.
doveconf: Fatal: Error in configuration file /usr/local/etc/dovecot/conf.d/10-ssl.conf line 12: ssl_cert: Can't open file /etc/dovecot/ssl/dovecot.crt: No such file or directory
/usr/local/etc/rc.d/dovecot: WARNING: failed to start dovecot
Create certificates:
# edit
mcedit /usr/local/share/examples/dovecot/dovecot-openssl.cnf
# create directories
mkdir /etc/ssl/certs /etc/ssl/private
# create certificates
sh mkcert.sh
# set permissions
chmod -R 0444 /etc/ssl/certs/
chmod -R 0400 /etc/ssl/private/
Start it:
root@v09:/usr/ports/mail/dovecot2 # /usr/local/etc/rc.d/dovecot start
Starting dovecot.
Can't open log file /var/log/dovecot/error.log: No such file or directory
/usr/local/etc/rc.d/dovecot: WARNING: failed to start dovecot
Create a log directory:
Start Dovecot successfully.
Test
Sign in to webmail as a user. An error occurs. Logs show: Could not connect to mail:143: php_network_getaddresses: getaddrinfo failed. Fix it by adding this to /etc/hosts:
Sign in again. A different error occurs:
# log Roundcube
IMAP Error: Login failed for [email protected] from 192.168.112.155. AUTHENTICATE PLAIN: * BYE Internal error occurred.
# log Dovecot
2014-10-15 12:26:00 imap: Error: user [email protected]: Relative home directory paths not supported: domain.com/test/
2014-10-15 12:26:00 imap: Error: Invalid user settings. Refer to server log for more information.
A known PostfixAdmin issue. Update the relative mailbox path to an absolute path in the database. The directory does not exist, so create it:
Sign in to webmail once more. Successful. Send a test message externally. Successful.
When trying to send mail from the local Exim host:
echo "test message body" | mail -v -s "subject test" [email protected]
tail /var/log/exim/main.log
remote host address is the local host: hostname (while verifying from host localhost (hostname) [127.0.0.1])
H=localhost (hostname) [127.0.0.1] sender verify defer for : remote host address is the local host
H=localhost (hostname) [127.0.0.1] F= temporarily rejected RCPT : Could not complete sender verify
Check delivery to a local user. It fails.
exim -bt root
[email protected] is undeliverable: Unknown user or alias
Cause: /etc/mail/mailer.conf had incorrect values and there was no [email protected] alias.
Test from an adjacent MSExchange 2010: Mail from Exchange 2010 on the adjacent LAN does not arrive. The log shows:
2014-10-15 17:45:54 H=(MX.EXTERNAL.DOMAIN) [192.168.112.59] F= temporarily rejected RCPT : host lookup deferred for reverse lookup check
Cause: The OS could not resolve 192.168.112.59 to a DNS name. Solution: configure the LAN DNS server so IP-to-DNS-name resolution works:
SpamAssassin: /usr/ports/mail/p5-Mail-SpamAssassin is obsolete; /usr/ports/mail/spamassassin/ is correct.
Uncomment the line in /usr/local/etc/exim/configure:
Add to the end of /etc/syslog.conf:
Restart Exim and start SpamAssassin. Check the logs. This appears:
2014-10-16 14:31:52 1XejHc-000HxY-9f SA: Debug: SAEximRunCond expand returned: '0'
2014-10-16 14:31:52 1XejHc-000HxY-9f SA: Action: Not running SA because SAEximRunCond expanded to false (Message-Id: 1XejHc-000HxY-9f). From (host=v09.domain.local [192.168.112.59]) for [email protected]
There is another configuration file: /usr/local/etc/sa-exim.conf. Change it as follows:
Restart Exim. The log shows:
2014-10-16 14:56:59 1Xejfv-000I1Q-1S SA: Action: scanned but message isn't spam: score=-0.3 required=5.0 (scanned in 0/0 secs | Message-Id: [email protected]). From (host=mailhost.firma.local [192.168.112.59]) for [email protected]
The log also shows that outgoing mail is scanned.