@@ -35,148 +35,32 @@ work, but usually it is worth doing it.
35
35
36
36
## Building a simple mailserver
37
37
38
- We are going to use this docker based mailserver:
39
- https://github.com/tomav/docker-mailserver We don't need to check for
40
- spam or viruses, we just need a simple mailserver to send emails from
41
- our applications (in this case from Moodle).
38
+ To install a simple SMTP server, follow the instructions here:
39
+ https://github.com/docker-scripts/postfix/blob/master/INSTALL.md
40
+ (or here: http://dashohoxha.fs.al/simple-smtp-server/ ).
42
41
42
+ You can set the SMTP settings with one of these alternatives:
43
43
44
- - First create a directory for the mailserver and get the setup script :
44
+ - Set ** SMTP_SERVER ** on ` settings.sh ` , like this :
45
45
```
46
- mkdir -p /var/ds/mail.example.org
47
- cd /var/ds/mail.example.org/
48
-
49
- curl -o setup.sh \
50
- https://raw.githubusercontent.com/tomav/docker-mailserver/master/setup.sh
51
- chmod a+x ./setup.sh
52
- ```
53
-
54
- - Create the file ` docker-compose.yml ` with a content like this:
46
+ ### You can build an SMTP server as described here:
47
+ ### https://github.com/docker-scripts/postfix/blob/master/INSTALL.md
48
+ SMTP_SERVER=smtp.example.org
49
+ SMTP_DOMAIN=example.org
55
50
```
56
- version: '2'
57
51
58
- services:
59
- mail:
60
- image: tvial/docker-mailserver:latest
61
- hostname: mail
62
- domainname: example.org
63
- container_name: mail
64
- ports:
65
- - "25:25"
66
- - "587:587"
67
- - "465:465"
68
- volumes:
69
- - ./data/:/var/mail/
70
- - ./state/:/var/mail-state/
71
- - ./config/:/tmp/docker-mailserver/
72
- - /var/ds/wsproxy/letsencrypt/:/etc/letsencrypt/
73
- environment:
74
- - PERMIT_DOCKER=network
75
- - SSL_TYPE=letsencrypt
76
- - ONE_DIR=1
77
- - DMS_DEBUG=1
78
- - SPOOF_PROTECTION=0
79
- - REPORT_RECIPIENT=1
80
- - ENABLE_SPAMASSASSIN=0
81
- - ENABLE_CLAMAV=0
82
- - ENABLE_FAIL2BAN=1
83
- - ENABLE_POSTGREY=0
84
- cap_add:
85
- - NET_ADMIN
86
- - SYS_PTRACE
52
+ - From the command line:
87
53
```
88
-
89
- For more details about the environment variables that can be used,
90
- and their meaning and possible values, check also these:
91
- - https://github.com/tomav/docker-mailserver#environment-variables
92
- - https://github.com/tomav/docker-mailserver/blob/master/.env.dist
93
-
94
- Make sure to set the propper ` domainname ` that you will use for the
95
- emails. We forward only SMTP ports (not POP3 and IMAP) because we
96
- are not interested in accessing the mailserver directly (from a
97
- client). We also use these settings:
98
- - ` PERMIT_DOCKER=network ` because we want to send emails from other
99
- docker containers.
100
- - ` SSL_TYPE=letsencrypt ` because we will manage SSL certificates
101
- with letsencrypt.
102
-
103
- - We need to open these ports on the firewall: ` 25 ` , ` 587 ` , ` 465 `
104
- ```
105
- ufw allow 25
106
- ufw allow 587
107
- ufw allow 465
108
- ```
109
- On your server you may have to do it differently.
110
-
111
- - Pull the docker image:
54
+ moosh config-set smtphosts smtp.example.org
55
+ moosh config-set smtpsecure TLS
56
+ moosh config-set smtpauthtype PLAIN
57
+ moosh config-set smtpuser ''
58
+ moosh config-set smtppass ''
59
+ moosh config-set smtpmaxbulk 100
112
60
```
113
- docker pull tvial/docker-mailserver:latest
114
- ```
115
-
116
- - Now generate the DKIM keys with ` ./setup.sh config dkim ` and copy
117
- the content of the file ` config/opendkim/keys/domain.tld/mail.txt `
118
- on the domain zone configuration at the DNS server. I use
119
- [ bind9] ( https://github.com/docker-scripts/bind9 ) for managing my
120
- domains, so I just paste it on ` example.org.db ` :
121
- ```
122
- mail._domainkey IN TXT ( "v=DKIM1; h=sha256; k=rsa; "
123
- "p=MIIBIjANBgkqhkiG9w0BAQEFACAQ8AMIIBCgKCAQEAaH5KuPYPSF3Ppkt466BDMAFGOA4mgqn4oPjZ5BbFlYA9l5jU3bgzRj3l6/Q1n5a9lQs5fNZ7A/HtY0aMvs3nGE4oi+LTejt1jblMhV/OfJyRCunQBIGp0s8G9kIUBzyKJpDayk2+KJSJt/lxL9Iiy0DE5hIv62ZPP6AaTdHBAsJosLFeAzuLFHQ6USyQRojefqFQtgYqWQ2JiZQ3"
124
- "iqq3bD/BVlwKRp5gH6TEYEmx8EBJUuDxrJhkWRUk2VDl1fqhVBy8A9O7Ah+85nMrlOHIFsTaYo9o6+cDJ6t1i6G1gu+bZD0d3/3bqGLPBQV9LyEL1Rona5V7TJBGg099NQkTz1IwIDAQAB" ) ; ----- DKIM key mail for example.org
125
-
126
- ```
127
-
128
- - Add these configurations as well on the same file on the DNS server:
129
- ```
130
- mail IN A 10.11.12.13
131
-
132
- ; mailservers for example.org
133
- 3600 IN MX 1 mail.example.org.
134
-
135
- ; Add SPF record
136
- IN TXT "v=spf1 mx ~all"
137
- ```
138
- Then don't forget to change the serial number and to restart the service.
139
-
140
- - Get an SSL certificate from letsencrypt. I use
141
- [ wsproxy] ( https://github.com/docker-scripts/wsproxy ) for managing
142
- SSL letsencrypt certificates of my domains:
143
- ```
144
- cd /var/ds/wsproxy
145
- ds domains-add mail mail.example.org
146
- ds get-ssl-cert myemail@gmail.com mail.example.org --test
147
- ds get-ssl-cert myemail@gmail.com mail.example.org
148
- ```
149
- Now the certificates will be available on
150
- ` /var/ds/wsproxy/letsencrypt/live/mail.example.org ` .
151
-
152
- - Start the mailserver and check for any errors:
153
- ```
154
- apt install docker-compose
155
- docker-compose up mail
156
- ```
157
-
158
- - Create email accounts and aliases:
159
- ```
160
- ./setup.sh email add admin@example.org passwd123
161
- ./setup.sh email add info@example.org passwd123
162
- ./setup.sh alias add admin@example.org myemail@gmail.com
163
- ./setup.sh alias add info@example.org myemail@gmail.com
164
- ./setup.sh email list
165
- ./setup.sh alias list
166
- ```
167
-
168
- Aliases make sure that any email that comes to these accounts is
169
- forwarded to my real email address, so that I don't need to use
170
- POP3/IMAP in order to get these messages. Also no anti-spam and
171
- anti-virus software is needed, making the mailserver lighter.
172
-
173
- - Send some test emails to these addreses and make other tests. Then
174
- stop the container with ` Ctrl+c ` and start it again as a daemon:
175
- ` docker-compose up mail -d ` .
176
61
177
- - Now save on Moodle configuration the SMTP settings and test by
178
- trying to send some messages to other users:
179
- - ** SMTP hosts** : ` mail.example.org:465 `
180
- - ** SMTP security** : ` SSL `
181
- - ** SMTP username** : ` info@example.org `
182
- - ** SMTP password** : ` passwd123 `
62
+ - From the admin interface (as described on the previous section):
63
+ - ** SMTP hosts** : ` smtp.example.org `
64
+ - ** SMTP security** : ` TLS `
65
+ - ** SMTP Auth Type** : ` PLAIN `
66
+ Leave empty username and password.
0 commit comments