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