Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| email:hosting [2025/03/02 19:39] – [Installation: postfixadmin web gui] willy | email:hosting [2025/03/03 06:57] (current) – removed willy | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== E-Mail server hosting ====== | ||
| - | |||
| - | Everything in the following page is directly taken (and adjusted to my liking) from [[https:// | ||
| - | |||
| - | |||
| - | ===== Architecture ===== | ||
| - | |||
| - | I will show you how to install and interconnect: | ||
| - | * [[https:// | ||
| - | * [[https:// | ||
| - | * NGINX + PHP-FPM for web access (admin console + webmail) | ||
| - | * [[https:// | ||
| - | * Roundcube | ||
| - | * OpenDKIM | ||
| - | * OpenDMARC | ||
| - | * Spamassassin | ||
| - | |||
| - | |||
| - | ===== Installation: | ||
| - | |||
| - | Install Postfix and Dovecot | ||
| - | |||
| - | USE flags: | ||
| - | <code bash> | ||
| - | echo "*/* maildir dovecot sasl" >> / | ||
| - | echo " | ||
| - | echo " | ||
| - | echo " | ||
| - | </ | ||
| - | |||
| - | Emerge the servers: | ||
| - | <code bash> | ||
| - | emerge -vp postfix dovecot | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== Installation: | ||
| - | |||
| - | Since different pieces of the email infrastructure will need to interoperate, | ||
| - | |||
| - | <code bash> | ||
| - | groupadd -g 5000 vmail | ||
| - | useradd -m -d /home/vmail -s /bin/false -u 5000 -g vmail vmail | ||
| - | chmod 2770 / | ||
| - | </ | ||
| - | |||
| - | The resulting permissions should look like: | ||
| - | <code bash> | ||
| - | ls -ld /home/vmail | ||
| - | drwxrws--- 3 vmail vmail 4096 Aug 2 07:24 /home/vmail | ||
| - | </ | ||
| - | |||
| - | FIX QUI I PERMESSI DEL DB | ||
| - | |||
| - | Now create the database: | ||
| - | <code bash> | ||
| - | su - vmail | ||
| - | mkdir db | ||
| - | sqlite3 db/ | ||
| - | sqlite> .databases | ||
| - | main: / | ||
| - | sqlite> .tables | ||
| - | sqlite> .exit | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== Installation: | ||
| - | |||
| - | postfixadmin and roundcube will be installed manually and not via Gentoo portage, to avoid upgrade issues. | ||
| - | |||
| - | Download latest release of **postfixadmin** from [[https:// | ||
| - | <code bash> | ||
| - | su # do this as root! You don't need to make postfixadmin writable by the web user | ||
| - | cd /home/web | ||
| - | mkdir postfixadmin | ||
| - | cd postfixadmin | ||
| - | wget https:// | ||
| - | tar xvf postfixadmin-3.3.15.tar.gz | ||
| - | mv postfixadmin-postfixadmin-3.3.15 postfixadmin | ||
| - | #The following folder must be writeable by web user: | ||
| - | mkdir -p postfixadmin/ | ||
| - | chown -R web postfixadmin/ | ||
| - | </ | ||
| - | |||
| - | Now, configure it by creating a file called **postfixadmin/ | ||
| - | <file - config.local.php> | ||
| - | <?php | ||
| - | $CONF[' | ||
| - | $CONF[' | ||
| - | $CONF[' | ||
| - | $CONF[' | ||
| - | $CONF[' | ||
| - | $CONF[' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | $CONF[' | ||
| - | $CONF[' | ||
| - | /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: | ||
| - | </ | ||
| - | |||
| - | Now setup NGINX to point to it. You need of course to setup a certbot certificate, | ||
| - | <file postfixadmin.conf> | ||
| - | server { | ||
| - | server_name mail.mydomain.com; | ||
| - | listen 443 ssl; | ||
| - | |||
| - | access_log / | ||
| - | error_log / | ||
| - | | ||
| - | index index.php; | ||
| - | | ||
| - | root / | ||
| - | |||
| - | # Uncomment the following lines only AFTER setup is complete! | ||
| - | # location ~ / | ||
| - | # deny all; | ||
| - | # alias / | ||
| - | # } | ||
| - | | ||
| - | location ~ /.*\.php$ { | ||
| - | try_files $uri =404; | ||
| - | fastcgi_split_path_info ^(.+\.php)(/ | ||
| - | include fastcgi_params; | ||
| - | fastcgi_param SCRIPT_FILENAME $request_filename; | ||
| - | fastcgi_pass 127.0.0.1: | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | restart NGINX and go to the URL **https:// | ||
| - | |||
| - | Also don't forget to create a superadmin-account. I suggest you call it **user@mydomain.com** and set a password you will not forget. | ||
| - | |||
| - | Go back, uncomment the lines in the NGINX config file to disable the setup.php, and restart NGINX. | ||
| - | |||
| - | __note:__ when adding new domains, choose " | ||
| - | |||
| - | At this point, you can already create all the mail domains and user accounts you want. | ||
| - | |||
| - | |||
| - | ===== Configuration: | ||
| - | |||
| - | Link to SQL. | ||
| - | |||
| - | File: **/ | ||
| - | <file - virtual_mailbox_domains.cf> | ||
| - | dbpath = / | ||
| - | query = SELECT domain FROM domain WHERE domain = ' | ||
| - | </ | ||
| - | |||
| - | File: **/ | ||
| - | <file - virtual_mailbox_maps.cf> | ||
| - | dbpath = / | ||
| - | query = SELECT maildir FROM mailbox WHERE local_part=' | ||
| - | </ | ||
| - | |||
| - | File: **/ | ||
| - | <file - virtual_alias_maps.cf> | ||
| - | dbpath = / | ||
| - | query = SELECT goto FROM alias WHERE address=' | ||
| - | </ | ||
| - | |||
| - | Now, link it all in **/ | ||
| - | < | ||
| - | # A list of all virtual domains serviced by this instance of postfix. | ||
| - | virtual_mailbox_domains = sqlite:/ | ||
| - | # Look up the mailbox location based on the email address received. | ||
| - | virtual_mailbox_maps = sqlite:/ | ||
| - | # Any aliases that are supported by this system | ||
| - | virtual_alias_maps = sqlite:/ | ||
| - | </ | ||
| - | |||
| - | ===== Installation: | ||
| - | |||
| - | This step is **mandatory** and critical for proper email delivery. | ||
| - | |||
| - | |||
| - | ===== Installation: | ||
| - | |||
| - | Install spamassassin & amavisd-new | ||
| - | |||
| - | |||
| - | FILE / | ||
| - | < | ||
| - | # Link the mailbox uid and gid to postfix. | ||
| - | virtual_uid_maps = static:5000 | ||
| - | virtual_gid_maps = static:5000 | ||
| - | |||
| - | # Set the base address for all virtual mailboxes | ||
| - | virtual_mailbox_base = /var/vmail | ||
| - | </ | ||