If you have ever built a mail server from the ground up, you’ll know that it can be a tedious venture. There is another option for those of us who don’t want to spend the time editing countless configuration files. iRedMail is an amazing shell script that automatically installs and configures all the components necessary for a fully functional mail server. iRedMail uses a complete package of open-source software including:<\/p>\n
Postfix<\/code>\u00a0– Mail transfer agent (MTA).<\/li>\nDovecot<\/code>\u00a0– POP3 and IMAP server.<\/li>\nApache<\/code>,\u00a0Nginx<\/code>\u00a0– Web server.<\/li>\nOpenLDAP<\/code>,\u00a0Idapd<\/code>\u00a0– LDAP server for storing mail accounts.<\/li>\nMySQL<\/code>,\u00a0MariaDB<\/code>,\u00a0PostgreSQL<\/code>\u00a0– SQL server for application data. Can also be used to store mail accounts.<\/li>\nSpamAssassin<\/code>\u00a0– spam scanner.<\/li>\nClamAV<\/code>\u00a0– Virus scanner.<\/li>\nAmavisd-new<\/code>\u00a0– Interface between Postfix, SpamAssassin and ClamAV.<\/li>\nRoundcube<\/code>\u00a0– Webmail client.<\/li>\nSOGo Groupware<\/code>\u00a0– Calendar, contact and tasks service.<\/li>\nFail2ban<\/code>\u00a0– Bans IPs that look malicious.<\/li>\nAwstats<\/code>\u00a0– Apache and Postfix log analyzer.<\/li>\niRedAPD<\/code>\u00a0– Postfix policy server.<\/li>\n<\/ul>\nIn this tutorial, we will walk through all of the steps to get your mail server running and get it secured with SSL using Let’s Encrypt.<\/p>\n
Prerequisites<\/h2>\n\n- An Ubuntu 16.04 instance with at least 2GB memory. A fresh installation is recommended.<\/li>\n
- A\u00a0non-root sudo user<\/a><\/strong><\/span>.<\/li>\n
- A non-blacklisted IP address. If your IP address is on a blacklist it could prevent your emails from ever reaching their destination.<\/li>\n<\/ul>\n
Installation With iRedMail<\/h2>\n
Before getting started with the installation, you should update your system.<\/p>\n
sudo apt-get update\r\nsudo apt-get upgrade\r\n<\/code><\/pre>\nNext, we will want to set our fully qualified domain name (FQDN) hostname. On Ubuntu, the hostname is set in 2 files,\u00a0\/etc\/hostname<\/code>\u00a0and\u00a0\/etc\/hosts<\/code>.<\/p>\nOpen\u00a0\/etc\/hostname<\/code>.<\/p>\nsudo nano \/etc\/hostname\r\n<\/code><\/pre>\nAdd your short hostname to the file, not your FQDN. If your full domain is\u00a0mail.example.com<\/code>\u00a0your file should look like this.<\/p>\nmail\r\n<\/code><\/pre>\nNext, open\u00a0\/etc\/hosts<\/code>\u00a0and add your FQDN.<\/p>\n127.0.0.1 mail.example.com mail localhost localhost.localdomain\r\n<\/code><\/pre>\nReboot your server.<\/p>\n
sudo shutdown -r now\r\n<\/code><\/pre>\nYou can now verify your hostname.<\/p>\n
hostname -f\r\n<\/code><\/pre>\nNow that your FQDN has been set, we can move onto the installation. Download the latest version of iRedMail using\u00a0wget<\/code>. You can find the latest build by visiting the\u00a0iRedMail download page<\/a><\/strong><\/span>.<\/p>\nwget https:\/\/bitbucket.org\/zhb\/iredmail\/downloads\/iRedMail-0.9.7.tar.bz2\r\n<\/code><\/pre>\nNext, extract the tarball and then\u00a0cd<\/code>\u00a0to the directory.<\/p>\ntar xvf iRedMail-0.9.7.tar.bz2\r\ncd iRedMail-0.9.7\r\n<\/code><\/pre>\nThen, add permission to the script and run it with sudo.<\/p>\n
chmod +x iRedMail.sh\r\nsudo bash iRedMail.sh\r\n<\/code><\/pre>\nYou will see a setup wizard that will ask you some questions:<\/p>\n
\n- Where you would like to store your mailboxes. The default location is\u00a0
\/var\/vmail<\/code>.<\/li>\n- Which web server you would like to use.<\/li>\n
- The backend to use for storing your mail. If you choose MySQL or MariaDB you will also need to set the SQL root password. This should be a strong password and avoid using special characters as this will cause errors.<\/li>\n
- Your first mail domain. This will be your domain from earlier minus the sub-domain. For example if you set your domain as\u00a0
mail.example.com<\/code>\u00a0then you would enter\u00a0example.com<\/code>\u00a0as your first mail domain name.<\/li>\n- Your domain administrator password, also avoiding special characters.<\/li>\n
- Which optional components you would like installed. Minimally you should select\u00a0
Roundcube<\/code>\u00a0and\u00a0iRedAdmin<\/code>.<\/li>\n<\/ul>\nNow that everything has been entered, we just need to review the settings and begin the installation. After installation you will be asked if you would like to use the firewall rules provided by iRedMail. The rule will be copied to\u00a0\/etc\/default\/iptables<\/code>. To use this option enter “y<\/code>” and continue. You will then be shown some vital data including:<\/p>\n\n- Roundcube webmail URL.<\/li>\n
- SOGo groupware URL.<\/li>\n
- Web admin panel URL.<\/li>\n
- Login username and password.<\/li>\n<\/ul>\n
This data can also be found at\u00a0\/home\/yourusername\/iRedMail-0.9.7\/iRedMail.tips<\/code>.<\/p>\nReboot your server.<\/p>\n
sudo shutdown -r now\r\n<\/code><\/pre>\nAfter rebooting, you can access the web admin page at\u00a0https:\/\/mail.example.com\/iredadmin<\/code>\u00a0using your domain. To access your email, use the Roundcube page at\u00a0https:\/\/mail.example.com\/mail<\/code>. iRedMail installs the server with a self-signed certificate which requires special permissions to open the page in your browser. It is recommended that you upgrade to an official CA certificate. Let’s Encrypt is a CA that offers free certificates. Visit\u00a0Setup LetsEncrypt on Linux<\/strong><\/span><\/a>\u00a0for information on using this service. Once the certificate is obtained you will need to replace the self-signed certs.<\/p>\nsudo cp \/path\/to\/your\/cert \/etc\/ssl\/certs\/iRedMail.crt\r\nsudo cp \/path\/to\/your\/key \/etc\/ssl\/private\/iRedMail.key\r\n<\/code><\/pre>\nRestart all services using the key. If you’ve used Nginx for your web server you would replace\u00a0apache2<\/code>\u00a0with\u00a0nginx<\/code>.<\/p>\nsudo systemctl restart postfix\r\nsudo systemctl restart apache2\r\nsudo systemctl restart dovecot<\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[242,245,247],"manual_kb_tag":[415],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2744"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2744"}],"version-history":[{"count":3,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2744\/revisions"}],"predecessor-version":[{"id":2751,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2744\/revisions\/2751"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2744"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2744"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}