summaryrefslogtreecommitdiff
path: root/guix/vkraus/modules/mail.scm
blob: 22f7eaaa0df1e9bf61c41505dcfdfce7c2eef053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(define-module (vkraus modules mail)
  #:use-module (gnu services)
  #:use-module (gnu services mail)
  #:use-module (guix gexp)
  #:use-module (guix modules)
  #:use-module (guix records)
  #:use-module (ice-9 match)
  #:use-module (ice-9 optargs))

(define-public (make-smtp-service domain srs-key srs-key-backup)
  (let ((cfg
	 (mixed-text-file "opensmtpd-configuration"
			  "
table aliases file:/etc/aliases
table blacklist file:" (plain-file "blacklist" "@toto.com") "

pki " domain " cert \"/etc/letsencrypt/live/" domain "/fullchain.pem\"
pki " domain " key \"/etc/letsencrypt/live/" domain "/privkey.pem\"

srs key \"" srs-key "\"
srs key backup \"" srs-key-backup "\"

listen on 0.0.0.0 port 25 tls pki " domain "
listen on :: port 25 tls pki " domain "
listen on 0.0.0.0 port 587 tls-require pki " domain " mask-src auth
listen on :: port 587 tls-require pki " domain " mask-src auth
listen on 0.0.0.0 port 465 smtps pki " domain " mask-src auth
listen on :: port 465 smtps pki " domain " mask-src auth
listen on socket mask-src
listen on lo port 10028 tag DKIM_SIGNED

action receive maildir alias <aliases>
action send relay helo " domain " srs
action sign relay host smtp://localhost:11333

match tag DKIM_SIGNED for any action send
match !from auth mail-from \"@" domain "\" for any reject
match from any mail-from <blacklist> reject
match from any for domain \"" domain "\" action receive
match from auth for local action receive
match from auth for any action sign
")))
    (service opensmtpd-service-type
	     (opensmtpd-configuration
	      (config-file cfg)))))