Saturday 13 September 2014

UNIX Mail server


A no-frills Mail Server running on Cent-OS / Fedora

preliminaries


update your OS with
yum -y update
fix all errors, if any and in case of kernel updates you need to run
shutdown -r now ( or later if someone else is using the box )
erase to good `ol sendmail and if it is installed for some reason exim with
yum -y erase sendmail exim
install Postfix the Mail Transfer Agent, Dovecot the Mail Delivery Agent and Clamav the Virus checker to protect or Windows community. We start with these two
yum -y install postfix dovecot
Spam could be a worry if we open the mail delivery to the server to the world. Since we only accept mail from white-listed senders we don't need to worry.

configuration


configure Postfix
cd /etc/postfix
fix the aliases file
create a my_networks file
create a body_checks file
create a header_checks file
set-up the main.cf file
set-up the master.cf file
now check the configs with
postfix check
then, if everything is fixed run
service postfix start
configure dovecot
cd /etc/dovecot
change the settings in dovecot.conf
cd conf.d
adjust all required *.conf files to suit
start dovecot and check the mail logs
service dovecot start
next set-up mail users, in our case for gitlab, jira and confluence and a postmaster account
add the users, ideally with the same id(s) as on other servers
create passwords for the mail set-up within the application
create home directories and set-up the Maildir within.
test the mail delivery to the postmaster account
and next test the out-going mail too
now you are ready to add the mail box details to the application and ensure to fully test the configuration. Once fully tested and working you can forget the passwords as changing passwords is a manual process on server and application.
as everything is working with the basics we add the Virus checking and the SSL certificates.
First we install and configure the Virus checker tools with
yum -y install clamav clamav-data clamav-filesystem clamav-lib clamav-server clamav-update clamsmtp
The configuration is needed for regular updates and Postfix integration
set-up the clamd.server config
set-up the freshclam.conf file
set-up the camsmtp.conf file
add the filter to the postfix main.cf and master.cf
now get the first clam database with
/bin/freshclam --verbose
service clamd.server start
service clamsmtp start
postfix stop
postfix start
re-test mail sending and receiving via the virus checker and watch
tail -f /var/log/maillog
fix any errors
lastly we can add the optional SSL certificates for sending and downloading email in non-clear text.
create the certs and place the into /etc/postfix/ssl
then add the certs and smtpd setting into the mail.cf and the dovecot configs
then restart postfix and dovecot and re-test the mail send/receive
service dovecote restart
postfix stop
postfix start
tail -f /var/log/maillog
fix any errors
When the SSL certs are installed and show no errors, the application(s) need to be changed to pop3 over SSL and send with TLS/SSL. It should just work or else more fixing.
Lastly inform users where send mail to and how to use the mail functionality in the application.

No comments: