mail - xxooxxooxx/xxooxxooxx.github.io GitHub Wiki

Postfix

telnet 192.168.0.2 25                           # Comments
Trying 192.168.0.2...
Connected to 192.168.0.2 (192.168.0.2).
Escape character is '^]'.
220 mail.example.com ESMTP Postfix              # <-smtp_client_restrictions
HELO mail.example.com                           # <-smtp_helo_restrictions
250 mail.example.com                            #
MAIL FROM:<[email protected]>                     # <-smtp_sender_restrictions
250 2.1.0 Ok                                    #
RCPT TO:<[email protected]>                       # <-smtp_recipient_restrictions
250 2.1.5 Ok                                    #
DATA                                            # <-smtp_data_restrictions
354 End data with <CR><LF>.<CR><LF>             #
To:<[email protected]>                            # <-header_checks
From:<[email protected]>                          #
Subject:SMTP Test                               #
This is a test message                          # <-body_checks
.                                               #
250 2.0.0 Ok: queued as 301AE20034
QUIT
221 2.0.0 Bye
Connection closed by foreign host.

OpenSMTPD&filter-rspamd

wget https://go.dev/dl/go1.19.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.19.3.linux-amd64.tar.gz
echo 'export GOROOT=/usr/local/go' > /etc/profile.d/golang.sh
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile.d/golang.sh
source /etc/profile.d/golang.sh

git clone https://github.com/poolpOrg/filter-rspamd
cd filter-rspamd
go build

mkdir /usr/local/libexec/opensmtpd
sudo install -m 0555 filter-rspamd /usr/local/libexec/opensmtpd/filter-rspamd
sudo install -m 0644 filter-rspamd.8 /usr/local/man/man8/filter-rspamd.8

multi domains

  • Postfix 3.4

/etc/postfix/main.cf

.
virtual_mailbox_domains = example1.org example2.org
.
#smtpd_tls_cert_file=/etc/letsencrypt/live/example1.org/fullchain.pem
#smtpd_tls_key_file=/etc/letsencrypt/live/example1.org/privkey.pem

smtpd_tls_chain_files =
 /etc/letsencrypt/live/example1.org/privkey.pem,
 /etc/letsencrypt/live/example1.org/fullchain.pem
.
tls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map
.

/etc/postfix/vmail_ssl.map

example2.org /etc/letsencrypt/live/example2.org/privkey.pem /etc/letsencrypt/live/example2.org/fullchain.pem
mail.example2.org /etc/letsencrypt/live/example2.org/privkey.pem /etc/letsencrypt/live/example2.org/fullchain.pem
smtp.example2.org /etc/letsencrypt/live/example2.org/privkey.pem /etc/letsencrypt/live/example2.org/fullchain.pem
postmap -F hash:/etc/postfix/vmail_ssl.map
systemctl restart postfix
  • Dovecot

/etc/dovecot/dovecot.conf

ssl_cert = </etc/letsencrypt/live/example1.org/fullchain.pem
ssl_key = </etc/letsencrypt/live/example1.org/privkey.pem
.
local_name example2.org {
  ssl_cert = </etc/letsencrypt/live/example2.org/fullchain.pem
  ssl_key = </etc/letsencrypt/live/example2.org/privkey.pem
}

local_name mail.example2.org {
  ssl_cert = </etc/letsencrypt/live/example2.org/fullchain.pem
  ssl_key = </etc/letsencrypt/live/example2.org/privkey.pem
}

local_name imap.example2.org {
  ssl_cert = </etc/letsencrypt/live/example2.org/fullchain.pem
  ssl_key = </etc/letsencrypt/live/example2.org/privkey.pem
}

  • Testing
openssl s_client -connect localhost:25 -servername SNI_name -starttls smtp
openssl s_client -connect localhost:587 -servername SNI_name -starttls smtp
openssl s_client -connect localhost:465 -servername SNI_name

openssl s_client -connect localhost:143 -servername SNI_name -starttls imap
openssl s_client -connect localhost:993 -servername SNI_name
⚠️ **GitHub.com Fallback** ⚠️