Following script may be used for configuring complete and secure email server on fresh install of Debian 9. It will probably work on other distributions using apt-get. After minor changes you'll be able to use it on other Linux distros.
This installer is created by solusipse: https://gist.github.com/solusipse/7ed8e1da104baaee3f05 with enhancements from the following forks:
- Install Postfix and configure it with TLS support.
- Install Dovecot and configure it's transport on Postfix.
- Download, extract and correct permissions for Postfixadmin.
- Download, extract and correct permissions for Roundcube.
This script is optional. It's intended to use only for nginx (I did not review this one from the fork).
- Install opendkim packages.
- Configure opendkim for the given domain (prompt at the script).
- Set directories tree and files for the domain key at "/etc/opendkim/".
- The script can be used more than once, to configure new domains (warns will appear when needed).
- It does not configure automatically postfixadmin, neither virtualhosts on apache.
- It does not configure automatically roundcube, neither virtualhosts on apache.
- It does not set anything related to DNS, those must be set manually (but it warns about).
- It does not configure Apache in no way whatsoever.
- It does not mess or set anything related with DNS server configuration.
- Run
postfix.shscript. - Configure postgres to allow connections.
- Configure postfix admin. Remember to set these:
$CONF['configured'] = true;
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'YES';
$CONF['database_type'] = 'pgsql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix_user';
$CONF['database_password'] = 'PASSWORD FROM INSTALLER SCRIPT';
$CONF['database_name'] = 'postfix_db';
- Create domain and at least one user.
- Configure roundcube. Set imap to port
993, host to: ssl://localhost. Set smtp to port587, host to tls://localhost. - Ran and configure opendkim.sh to install opendkim and generate new keys for the given domain.
This is just a draft right now, it will be updated.