Projekt

Allgemein

Profil

Config postfix smarthost » Historie » Version 1

Jeremias Keihsler, 22.11.2022 08:49

1 1 Jeremias Keihsler
h1. Config postfix smarthost
2
3
currently we are using Ubuntu only as a base for mailcow.
4
So things are a bit different here, see also: https://docs.mailcow.email/post_installation/firststeps-local_mta/
5
6
h2. install postfix and mail
7
8
<pre><code class="shell">
9
sudo apt install mailutils
10
</code></pre>
11
12
h2. configure postfix
13
14
<pre><code class="shell">
15
sudo vim /etc/postfix/master.cf
16
</code></pre>
17
18
<pre>
19
#smtp      inet  n       -       -       -       -       smtpd
20
</pre>
21
22
<pre><code class="shell">
23
sudo vim /etc/postfix/main.cf
24
</code></pre>
25
26
<pre>
27
# as per https://docs.mailcow.email/post_installation/firststeps-local_mta/
28
relayhost = 172.22.1.1
29
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
30
inet_interfaces = loopback-only
31
relay_transport = relay
32
default_transport = smtp
33
</pre>
34
35
additionally we need to know the server and email-address as well as the password to use
36
<pre><code class="shell">
37
vim /etc/postfix/sasl_passwd
38
</code></pre>
39
40
<pre>
41
mail.example.com:587     mailadr@example.com:password
42
</pre> 
43
44
The above server hostname and port must exactly match the value for "relayhost" in /etc/postfix/main.cf.
45
46
Generate a postfix lookup table from the previous file
47
<pre><code class="shell">
48
postmap hash:/etc/postfix/sasl_passwd
49
</code></pre>
50
51
Test the lookup table, if all is good then the following will return the specified username:password
52
<pre><code class="shell">
53
postmap -q mail.example.com:587 /etc/postfix/sasl_passwd
54
</code></pre>
55
56
next is to bind the local username to the email-address. You may also have a look into @/etc/aliases@ and check who's mail are sent to whom.
57
<pre><code class="shell">
58
vim /etc/postfix/canonical
59
</code></pre>
60
61
<pre>
62
root     mailadr@example.com
63
</pre> 
64
65
The above email-address must exactly match the email-address in sasl_passwd.
66
67
Generate a postfix lookup table from the previous file
68
<pre><code class="shell">
69
postmap hash:/etc/postfix/canonical
70
</code></pre>
71
72
Make sure that sasl_passwd and sasl_passwd.db files are readable/writeable only by root
73
<pre><code class="shell">
74
chmod 600 /etc/postfix/sasl_passwd
75
chmod 600 /etc/postfix/sasl_passwd.db
76
</code></pre>
77
78
Add postfix to be started at boot
79
<pre><code class="shell">
80
systemctl enable postfix
81
</code></pre>
82
83
h3. maybe necessary
84
85
<pre><code class="shell">
86
sudo mkfifo /var/spool/postfix/public/pickup
87
</code></pre>