{"id":122,"date":"2023-05-18T07:56:44","date_gmt":"2023-05-18T14:56:44","guid":{"rendered":"https:\/\/www.cmsws.com\/blog\/?p=122"},"modified":"2023-05-27T05:52:53","modified_gmt":"2023-05-27T12:52:53","slug":"how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11","status":"publish","type":"post","link":"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/","title":{"rendered":"Debian 11 Mail Server setup"},"content":{"rendered":"\n<p>How to Set Up a Mail Server with Postfix, Dovecot and PostfixAdmin on Debian 11<\/p>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Log_in_via_SSH_and_update_the_system\" >Log in via SSH and update the system<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Set_Hostname\" >Set Hostname<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Install_Apache_MariaDB_and_PHP\" >Install Apache, MariaDB, and PHP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Create_a_System_User\" >Create a System User<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Create_a_Database\" >Create a Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Install_Postfix\" >Install Postfix<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Install_Dovecot\" >Install Dovecot<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/#Install_PostfixAdmin\" >Install PostfixAdmin<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>Here I will document building a new mail server to replace my existing server. I will install this in a virtual server on my <a href=\"https:\/\/www.proxmox.com\/\">ProxMox<\/a> server. My hardware requirements are very minimal. I will create a container with a 100GB drive capacity, 8GB of ram and 4 CPU cores.<\/p>\n\n\n\n<p>The server OS will be <a href=\"https:\/\/www.debian.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Debian<\/a> 11. I will be using <a href=\"https:\/\/www.postfix.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Postfix<\/a> as my MTA, <a href=\"https:\/\/www.dovecot.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dovecot<\/a> as my client authentication server for both IMAP and Pop3. The DB will be <a href=\"https:\/\/mariadb.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB<\/a>. I will use <a href=\"https:\/\/github.com\/postfixadmin\/postfixadmin\" target=\"_blank\" rel=\"noreferrer noopener\">PostfixAdmin<\/a> to manage the entire install.<\/p>\n\n\n\n<p>Prerequisites<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Debian 11 Server<\/li>\n\n\n\n<li>A regular system user with sudo privileges or root user access<\/li>\n\n\n\n<li>A Fully Qualified Domain Name (FQDN)<\/li>\n\n\n\n<li>Access to making DNS entries for your FQDN<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Log_in_via_SSH_and_update_the_system\"><\/span>Log in via SSH and update the system<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Log in to your Debian 11 Server through SSH as a root user or as a regular user that has sudo privileges.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh user@hostname<\/code><\/pre>\n\n\n\n<p>To update the system, you can run this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt upgrade<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Set_Hostname\"><\/span>Set Hostname<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You would need to create a DNS A record for your hostname because the server hostname should be an FQDN. For example, we will create debian11.yourdomain.com as the server hostname, let\u2019s run this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo hostnamectl set-hostname debian11.yourdomain.com<\/code><\/pre>\n\n\n\n<p>The above command is just an example, you would need to use your own registered domain name to create a hostname.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Install_Apache_MariaDB_and_PHP\"><\/span>Install Apache, MariaDB, and PHP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Now, let\u2019s install the webserver, database server, and PHP<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2 mariadb-server php-{xml,pear,imap,intl,common,json,curl,mbstring,mysql,pgsql,gd,imagick,zip,opcache,sqlite3} libapache2-mod-php<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_System_User\"><\/span>Create a System User<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When creating the system user be mindfull of the available space the users partition is going to be created on.  Make sure you have enough space to house the volumn of email that will be received by all mail recipents.  Personally, I chose \/home as my base.  \/home is normally one of the first secondary partitions I create when installing a new system.<\/p>\n\n\n\n<p>Let\u2019s run the following commands to create a system user called \u2018vmail\u2019 and create a directory and give the proper permission.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo useradd -m -r -u 150 -g mail -d \/home\/vmail -s \/sbin\/nologin -c \"Virtual Mail User\" vmail\nsudo chmod -R 770 \/home\/vmail\nsudo chown -R vmail:mail \/home\/vmail<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_Database\"><\/span>Create a Database<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Lets first secure your root user database access.  Simply install MariaDB does not setup a default password for the root user.  Run the following command and follow the prompts given to you to secure your MySQL server installation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo su -\nmysql_secure_installation<\/code><\/pre>\n\n\n\n<p>Now, lets login to MySQL, run this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<p>Once logged in, let\u2019s run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB &#091;(none)]&gt; CREATE DATABASE postfixadmin;\nMariaDB &#091;(none)]&gt; GRANT ALL PRIVILEGES ON postfixadmin.* TO 'pfadmin'@'localhost' IDENTIFIED BY 'Pa$$W0rd';\nMariaDB &#091;(none)]&gt; FLUSH PRIVILEGES;\nMariaDB &#091;(none)]&gt; \\q<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Install_Postfix\"><\/span>Install Postfix<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Install Postfix mail server with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install postfix-mysql<\/code><\/pre>\n\n\n\n<p>Once executes, you will see the following set up a mail server with PostfixAdmin on Debian 11<\/p>\n\n\n\n<p>Choose Internet Site then hit Ok to continue<\/p>\n\n\n\n<p>In this step, you will be asked for the system mail name, make sure the system mail name is the same as your Debian 11 hostname. We set the system hostname at the beginning of this tutorial.<\/p>\n\n\n\n<p>Once completed we need to create several configuration files for Postfix to communicate with the database.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/etc\/postfix\/sql<\/code><\/pre>\n\n\n\n<p>Let\u2019s create the files, make sure to replace the password, database name, database user with the ones you created earlier.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_alias_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT goto FROM alias WHERE address='%s' AND active = '1'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_domains_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT domain FROM domain WHERE domain='%s' AND active = '1'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_mailbox_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_alias_domain_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_alias_domain_mailbox_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_mailbox_limit_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/sql\/mysql_virtual_alias_domain_catchall_maps.cf\n\nuser = pfadmin\npassword = Pa$$W0rd\nhosts = localhost\ndbname = postfixadmin\nquery = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1'<\/code><\/pre>\n\n\n\n<p>Let us now proceed with editing \/etc\/postfix\/main.cf file, we can run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo postconf -e \"myhostname = $(hostname -f)\"\nsudo postconf -e \"mydestination = localhost\"\nsudo postconf -e \"mynetworks = 127.0.0.0\/8\"\nsudo postconf -e \"inet_protocols = ipv4\"\nsudo postconf -e \"inet_interfaces = all\"\nsudo postconf -e \"smtpd_tls_cert_file = \/etc\/ssl\/certs\/ssl-cert-snakeoil.pem\"\nsudo postconf -e \"smtpd_tls_key_file = \/etc\/ssl\/private\/ssl-cert-snakeoil.key\"\nsudo postconf -e \"smtpd_use_tls = yes\"\nsudo postconf -e \"smtpd_tls_auth_only = yes\"\nsudo postconf -e \"smtpd_sasl_type = dovecot\"\nsudo postconf -e \"smtpd_sasl_path = private\/auth\"\nsudo postconf -e \"smtpd_sasl_auth_enable = yes\"\nsudo postconf -e \"smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination\"\nsudo postconf -e \"virtual_transport = lmtp:unix:private\/dovecot-lmtp\"\nsudo postconf -e \"virtual_mailbox_domains = proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_domains_maps.cf\"\nsudo postconf -e \"virtual_alias_maps = proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_maps.cf, proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_domain_maps.cf, proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_domain_catchall_maps.cf\"\nsudo postconf -e \"virtual_mailbox_maps = proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_mailbox_maps.cf, proxy:mysql:\/etc\/postfix\/sql\/mysql_virtual_alias_domain_mailbox_maps.cf\"<\/code><\/pre>\n\n\n\n<p>Once completed, we can continue and edit \/etc\/postfix\/master.cf file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/postfix\/master.cf<\/code><\/pre>\n\n\n\n<p>Modify or add the following lines to the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>smtp inet n - y - - smtpd\n#smtp inet n - y - 1 postscreen\n#smtpd pass - - y - - smtpd\n#dnsblog unix - - y - 0 dnsblog\n#tlsproxy unix - - y - 0 tlsproxy\nsubmission inet n - y - - smtpd\n  -o syslog_name=postfix\/submission\n  -o smtpd_tls_security_level=encrypt\n  -o smtpd_sasl_auth_enable=yes\n# -o smtpd_reject_unlisted_recipient=no\n# -o smtpd_client_restrictions=$mua_client_restrictions\n# -o smtpd_helo_restrictions=$mua_helo_restrictions\n# -o smtpd_sender_restrictions=$mua_sender_restrictions\n# -o smtpd_recipient_restrictions=\n# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject\n  -o smtpd_client_restrictions=permit_sasl_authenticated,reject\n  -o milter_macro_daemon_name=ORIGINATING\nsmtps inet n - y - - smtpd\n  -o syslog_name=postfix\/smtps\n# -o smtpd_tls_wrappermode=yes\n  -o smtpd_sasl_auth_enable=yes\n# -o smtpd_reject_unlisted_recipient=no\n  -o smtpd_client_restrictions=permit_sasl_authenticated,reject\n# -o smtpd_client_restrictions=$mua_client_restrictions\n# -o smtpd_helo_restrictions=$mua_helo_restrictions\n# -o smtpd_sender_restrictions=$mua_sender_restrictions\n# -o smtpd_recipient_restrictions=\n# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject\n  -o milter_macro_daemon_name=ORIGINATING<\/code><\/pre>\n\n\n\n<p>Save the changes then exit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Install_Dovecot\"><\/span>Install Dovecot<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install dovecot-mysql dovecot-imapd dovecot-pop3d dovecot-lmtpd<\/code><\/pre>\n\n\n\n<p>Once dovecot is installed, we need to edit some configuration files.<\/p>\n\n\n\n<p>Open the \/etc\/dovecot\/conf.d\/10-auth.conf file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/etc\/dovecot\/conf.d\/10-auth.conf<\/code><\/pre>\n\n\n\n<p>Then find this line<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>auth_mechanisms = plain<\/code><\/pre>\n\n\n\n<p>replace it with this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>auth_mechanisms = plain login<\/code><\/pre>\n\n\n\n<p>Then, comment !include auth-system.conf.ext and uncomment #!include auth-sql.conf.ext<\/p>\n\n\n\n<p>It should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!include auth-system.conf.ext \n!include auth-sql.conf.ext<\/code><\/pre>\n\n\n\n<p>In the 10-auth.conf file, we include auth-sql.conf.ext. So, let\u2019s edit the file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/etc\/dovecot\/dovecot-sql.conf.ext<\/code><\/pre>\n\n\n\n<p>then append these lines:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>driver = mysql\nconnect = host=localhost dbname=postfixadmin user=pfadmin password=Pa$$W0rd\ndefault_pass_scheme = MD5-CRYPT\npassword_query = SELECT username as user, password, '\/home\/vmail\/%d\/%n' as userdb_home, 'maildir:\/home\/vmail\/%d\/%n' as userdb_mail, 150 as userdb_uid, 8 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'\nuser_query = SELECT '\/home\/vmail\/%d\/%u' as home, 'maildir:\/home\/vmail\/%d\/%u' as mail, 150 AS uid, 8 AS gid, concat('dirsize:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'<\/code><\/pre>\n\n\n\n<p>The lines above contain the database credentials, make sure they match the ones you created in the previous step.<\/p>\n\n\n\n<p>Save the file and exit<\/p>\n\n\n\n<p>Next, open the \/etc\/dovecot\/conf.d\/10-mail.conf file and modify the following values:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/etc\/dovecot\/conf.d\/10-mail.conf\n\nmail_location = maildir:\/home\/vmail\/%d\/%n\nmail_uid = vmail\nmail_gid = mail\nmail_privileged_group = mail\nfirst_valid_uid = 150\nlast_valid_uid = 150<\/code><\/pre>\n\n\n\n<p>By default, dovecot SSL support in Debian 11 is enabled. You can verify it by checking the file \/etc\/dovecot\/conf.d\/10-ssl.conf, make sure it has this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssl = yes<\/code><\/pre>\n\n\n\n<p>If you want to edit the postmaster email address, you can edit the file \/etc\/dovecot\/conf.d\/15-lda.conf and find the postmaster_address line. By default, the postmaster email address would be postmaster@yourdomain.com. So, if you want to receive the postmaster email at admin@yourdomain.com, then you need to add this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postmaster_address = admin@yourdomain.com<\/code><\/pre>\n\n\n\n<p>Now, let\u2019s proceed with editing other dovecot configuration files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/dovecot\/conf.d\/10-master.conf<\/code><\/pre>\n\n\n\n<p>There are several changes you need to make to this file.<\/p>\n\n\n\n<p>Find the service lmtp section and change it to the following:<\/p>\n\n\n\n<pre id=\"block-a70a93db-d892-4eee-9576-077844f1f1c3\" class=\"wp-block-code\"><code>service lmtp {<br>     unix_listener \/var\/spool\/postfix\/private\/dovecot-lmtp {<br>     mode = 0600<br>     user = postfix<br>     group = postfix<br>     }<br>}<\/code><\/pre>\n\n\n\n<p>Find the service auth section and change it to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service auth {\n     unix_listener \/var\/spool\/postfix\/private\/auth {\n     mode = 0666\n     user = postfix\n     group = postfix\n}\n\nunix_listener auth-userdb {\n     mode = 0600\n     user = vmail\n\n}\n\nuser = dovecot\n}<\/code><\/pre>\n\n\n\n<p>Change the service auth-worker section to the following:<\/p>\n\n\n\n<pre id=\"block-a70a93db-d892-4eee-9576-077844f1f1c3\" class=\"wp-block-code\"><code>service auth-worker {<br>     user = vmail<br>}<\/code><\/pre>\n\n\n\n<p>Do not forget to save the file then exit<\/p>\n\n\n\n<p>Before restarting Dovecot, we need to change the permissions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R vmail:dovecot \/etc\/dovecot\nsudo chmod -R o-rwx \/etc\/dovecot\nsudo systemctl restart postfix dovecot<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Install_PostfixAdmin\"><\/span>Install PostfixAdmin<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In this final step, we will download PostfixAdmin from Github and store it in the \/var\/www\/ directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/var\/www\/\nsudo wget -O postfixadmin.tgz https:\/\/github.com\/postfixadmin\/postfixadmin\/archive\/postfixadmin-3.3.15.tar.gz\nsudo tar zxf postfixadmin-3.3.15.tar.gz\nsudo ln -s postfixadmin-3.3.15 postfixadmin\nsudo mkdir -p postfixadmin\/templates_c\nsudo chown -R www-data. postfixadmin<\/code><\/pre>\n\n\n\n<p>Run composer installer to install PostfixAdmin PHP dependencies.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/var\/www\/postfixadmin\/<br>sudo composer install --no-dev<\/pre>\n\n\n\n<p>We are not going to use a subdomain to access PostfixAdmin through a web browser, we will use an Apache alias instead.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/apache2\/conf-enabled\/postfixadmin.conf<\/code><\/pre>\n\n\n\n<p>Paste the following into the file then reload apache.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Alias \/postfixadmin \/var\/www\/postfixadmin\/public\n&lt;Directory \"\/var\/www\/postfixadmin\/public\">\n        AllowOverride All\n        Options +FollowSymLinks\n        Require all granted\n&lt;\/Directory>\n\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<p>Create config.local.php and insert the following lines<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/opt\/postfixadmin\/config.local.php\n\n&lt;?php\n$CONF&#091;'database_type'] = 'mysqli';\n$CONF&#091;'database_host'] = 'localhost';\n$CONF&#091;'database_user'] = 'pfadmin';\n$CONF&#091;'database_password'] = 'Pa$$W0rd';\n$CONF&#091;'database_name'] = 'postfixadmin';\n$CONF&#091;'configured'] = true;\n\n?&gt;<\/code><\/pre>\n\n\n\n<p>Go to http:\/\/YOUR_SERVER_IP_ADDRESS\/postfixadmin\/setup.php and create a setup password. If you already have a website on your server, you can also access PostfixAdmin at http:\/\/yourdomain.com\/postfixadmin\/setup.php<\/p>\n\n\n\n<p>Type your setup password twice and click on the \u2018Generate setup_password hash\u2019 button.<\/p>\n\n\n\n<p>You will see a line containing a setup password like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$CONF&#091;'setup_password'] = '$2y$10$xlKkztMcpu6C3\/\/ZqPZM1.pTGjGD5oEn0KtBlbSl9VFDycxPNH1M2';<\/code><\/pre>\n\n\n\n<p>and you need to copy it to config.local.php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$CONF&#091;'database_type'] = 'mysqli';\n$CONF&#091;'database_host'] = 'localhost';\n$CONF&#091;'database_user'] = 'pfadmin';\n$CONF&#091;'database_password'] = 'Pa$$W0rd';\n$CONF&#091;'database_name'] = 'postfixadmin';\n$CONF&#091;'configured'] = true;\n\n$CONF&#091;'setup_password'] = '$2y$10$xlKkztMcpu6C3\/\/ZqPZM1.pTGjGD5oEn0KtBlbSl9VFDycxPNH1M2';\n?&gt;<\/code><\/pre>\n\n\n\n<p>After adding the line to config.local.php file, you can refresh the page to log in and create a superadmin.  <\/p>\n\n\n\n<p>That\u2019s it, after successfully adding a superadmin, you can use the credentials to log in to http:\/\/YOUR_SERVER_IP_ADDRESS\/postfixadmin\/login.php to add domains, email accounts, and any other email management tasks there.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Set Up a Mail Server with Postfix, Dovecot and PostfixAdmin on Debian 11 Here I will document building a new mail server to replace my existing server. I will install this in a virtual server on my ProxMox server. My hardware requirements are very minimal. I will create a container with a 100GB drive capacity, 8GB of ram [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-linux"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":21,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/122\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}