Projekt

Allgemein

Profil

Config postfix smarthost » Historie » Revision 2

Revision 1 (Jeremias Keihsler, 22.11.2022 08:49) → Revision 2/3 (Jeremias Keihsler, 05.04.2024 10:46)

h1. Config postfix smarthost 

 h2. smarthost with local mailcow-dockerized 

 currently we are using Ubuntu only as a base for mailcow. 
 So things are a bit different here, see also: https://docs.mailcow.email/post_installation/firststeps-local_mta/ 

 h3. h2. install postfix and mail 

 <pre><code class="shell"> 
 sudo apt install mailutils 
 </code></pre> 

 h3. h2. configure postfix 

 <pre><code class="shell"> 
 sudo vim /etc/postfix/master.cf 
 </code></pre> 

 <pre> 
 #smtp        inet    n         -         -         -         -         smtpd 
 </pre> 

 <pre><code class="shell"> 
 sudo vim /etc/postfix/main.cf 
 </code></pre> 

 <pre> 
 # as per https://docs.mailcow.email/post_installation/firststeps-local_mta/ 
 relayhost = 172.22.1.1 
 mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 
 inet_interfaces = loopback-only 
 relay_transport = relay 
 default_transport = smtp 
 </pre> 

 additionally we need to know the server and email-address as well as the password to use 
 <pre><code class="shell"> 
 vim /etc/postfix/sasl_passwd 
 </code></pre> 

 <pre> 
 mail.example.com:587       mailadr@example.com:password 
 </pre>  

 The above server hostname and port must exactly match the value for "relayhost" in /etc/postfix/main.cf. 

 Generate a postfix lookup table from the previous file 
 <pre><code class="shell"> 
 postmap hash:/etc/postfix/sasl_passwd 
 </code></pre> 

 Test the lookup table, if all is good then the following will return the specified username:password 
 <pre><code class="shell"> 
 postmap -q mail.example.com:587 /etc/postfix/sasl_passwd 
 </code></pre> 

 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. 
 <pre><code class="shell"> 
 vim /etc/postfix/canonical 
 </code></pre> 

 <pre> 
 root       mailadr@example.com 
 </pre>  

 The above email-address must exactly match the email-address in sasl_passwd. 

 Generate a postfix lookup table from the previous file 
 <pre><code class="shell"> 
 postmap hash:/etc/postfix/canonical 
 </code></pre> 

 Make sure that sasl_passwd and sasl_passwd.db files are readable/writeable only by root 
 <pre><code class="shell"> 
 chmod 600 /etc/postfix/sasl_passwd 
 chmod 600 /etc/postfix/sasl_passwd.db 
 </code></pre> 

 Add postfix to be started at boot 
 <pre><code class="shell"> 
 systemctl enable postfix 
 </code></pre> 

 h4. h3. maybe necessary 

 <pre><code class="shell"> 
 sudo mkfifo /var/spool/postfix/public/pickup 
 </code></pre>