Postgrey

Installation

pacman -S postgrey

Activate configuration

cp /usr/lib/systemd/system/postgrey.service /etc/systemd/system/

Add to Postfix configuration

/etc/postfix/main.cf

smtpd_recipient_restrictions =
	check_policy_service inet:127.0.0.1:10030

Add automated whitelist

/etc/systemd/system/postgrey.service

ExecStart=/usr/bin/postgrey --inet=127.0.0.1:10030 \
	--pidfile=/run/postgrey/postgrey.pid \
	--group=postgrey --user=postgrey \
	--daemonize \
	--greylist-text="Greylisted for %%s seconds" \
	--auto-whitelist-clients=5

systemctl deamon-reload
systemctl restart postgrey

Mailserver

Install

pacman -S postfix dovecot

Add User for Maildeamon

useradd -u 5000 -s /usr/bin/nologin -d /var/spool/mail/vmail/ -m vmail
mkdir -p /var/spool/mail/vmail/

Postfix

Create database

mysql -u root -p

CREATE DATABASE postfix;
CREATE USER “postfix_user”@“localhost” IDENTIFIED BY “blafoo”;
GRANT ALL ON postfix.* TO “postfix_user”@“localhost”;
FLUSH PRIVILEGES;

Create tables

Virtual domains

CREATE TABLE `virtual_domains` (
`id`  INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Virtual users

OpenDKIM

Installation

pacman -S opendkim
dnf install opendkim opendkim-tools

mkdir /etc/postfix/dkim
chown root:opendkim /etc/postfix/dkim -R

Create config

/etc/opendkim/opendkim.conf

AutoRestart             Yes
AutoRestartRate         10/1h
UMask                   002
Syslog                  yes
SyslogSuccess           Yes
LogWhy                  Yes
SendReports    		    yes
SoftwareHeader    	    yes

Canonicalization        relaxed/simple

KeyTable                /etc/postfix/dkim/KeyTable
ExternalIgnoreList      refile:/etc/postfix/dkim/TrustedHosts
InternalHosts           refile:/etc/postfix/dkim/TrustedHosts
SigningTable            refile:/etc/postfix/dkim/SigningTable

Mode                    sv
SignatureAlgorithm      rsa-sha256
MinimumKeyBits		    1024
OversignHeaders		    From
#QueryCache	        	yes

UserID                  opendkim:opendkim
Socket                  inet:12301@localhost

OversignHeaders		From

Add Dkim to Postfix

/etc/postfix/main.cf

# DKIM
milter_default_action 			= accept
non_smtpd_milters 			= inet:localhost:12301
smtpd_milters 				= inet:localhost:12301

Create directory for socket

mkdir /var/run/opendkim
chown opendkim:opendkim /var/run/opendkim