Skip to content

Postfix and RoundCube

Filip Krzyżanowski edited this page Nov 16, 2022 · 4 revisions

Installation

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install and enable required packages and extensions

     1. Install required packages

sudo apt install lsb-release apt-transport-https ca-certificates php8.1-imagick php8.1-intl php8.1-ldap -y

     2. Open php.ini file

sudo nano /etc/php/8.1/apache2/php.ini

     3. Uncomment below lines

extension=intl # Line 925 
extension=ldap # Line 927

     4. Add following line at the end of Dynamic extensions section

extension=imagick # Line 956

     4. Set your timezone in Date section

date.timezone = Europe/Warsaw # Line 969

3. Install Postfix mail server

sudo apt-get install postfix

During installation, you need to select Postfix type (To finish guide select "Internet Site") and type your server domain (For example: domain.com).

4. Verify installation and check that Postfix is running

sudo postconf mail_version
sudo systemctl status postfix

5. Install Dovecot IMAP and POP3 server

sudo apt-get install dovecot-imapd dovecot-pop3d -y

6. Restart Dovecot server

sudo systemctl restart dovecot

7. Go to main Apache2 directory

cd /var/www/html/

8. Download RoundCube archive

I am installing RC 1.6.0, but you can select RoundCube version here.
Remember to download ONLY COMPLETE versions

sudo wget https://github.com/roundcube/roundcubemail/releases/download/1.6.0/roundcubemail-1.6.0-complete.tar.gz

9. Extract archive

sudo tar -xvf /var/www/html/roundcubemail-1.6.0-complete.tar.gz

10. Change name of your directory with roundcube

sudo mv /var/www/html/roundcubemail-1.6.0 /var/www/html/roundcubemail

11. Change owner and permissions to RoundCube directory

sudo chown -R www-data:www-data /var/www/html/roundcubemail/
sudo chmod 755 -R /var/www/html/roundcubemail/

12. Prepare database for RoundCube

     1. Enter to MySQL

sudo mysql -u root -p

     2. Create database for RoundCube

CREATE DATABASE roundcube DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

     3. Create RoundCube user

CREATE USER roundcube@localhost IDENTIFIED BY 'password';

     4. Grant privileges to created user for created database

GRANT ALL PRIVILEGES ON roundcube.* TO roundcube@localhost;

     5. Refresh privileges granted to users

flush privileges;

     6. Exit from MySQL

quit;

     7. Import data from RoundCube initial SQL file

sudo mysql -u root -p roundcube < /var/www/html/roundcubemail/SQL/mysql.initial.sql

13. Create Apache2 Virtual Host for RoundCube

sudo nano /etc/apache2/sites-available/roundcube.conf 

And paste below code

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html/roundcubemail/
    
    ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log
    CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined
    
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    
    <Directory /var/www/html/roundcubemail/>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

14. Enable created Virtual Host

sudo a2ensite roundcube.conf

15. Reload Apache2 service to see effects

sudo systemctl reload apache2

Configuration

1. Enter RoundCube installer page

Go to page http://your-server.domain/roundcube/installer

You should see something like this img.png

2. Press NEXT button on bottom section of page

img_1.png

3. Set up config file

In database section type your credentials to roundcube database img_2.png

In SMTP section set up SMTP port to 25 img_9.png

Select useful extensions

  • Archive
  • Emoticons
  • Enigma
  • Filesystem_attachments
  • Hide_blockquote
  • Markasjunk
  • Newmail_notifier

4. Click CREATE CONFIG button on bottom section of page

img_3.png

You should see this notification on the top img_4.png

But if you see PHP file content, you should do this steps:

    1. Create config file for roundcube

sudo nano /var/www/html/roundcube/config/config.inc.php

     2. Paste content from RoundCube installer to this file

img_10.png

5. Press CONTINUE button and test this 2 sections

img_6.png If you see only OK after tests you can go forward

6. Remove installer directory from RoundCube

sudo rm -rf /var/www/html/roundcube/installer

7. Set up defaults for sending mails from localhost and allow to log to SMTP with no password

    1. Open default RoundCube config file

sudo nano /var/www/html/roundcube/config/defaults.inc.php

    2. Change following variables

$config['smtp_host'] = 'localhost:25'; # Line 272
$config['smtp_user'] = ''; # Line 276
$config['smtp_pass'] = ''; # Line 280

Save and exit.

    3. Open Postfix main configuration file

sudo nano /etc/postfix/main.cf

    4. Tell Postfix to trust localhost

In second line add following expression

mynetworks_style = host

8. Go to the RoundCube main page

Enter link http://your-server.domain/roundcube

You should see login page img_7.png

9. Login and start using RoundCube!

If you passed tests from installer you should have test messages in your inbox img_8.png

Clone this wiki locally