Changes for page How to setup a postfix SMTP server
Last modified by Alexandru Pentilescu on 2025/02/09 14:17
From version 9.1
edited by Alexandru Pentilescu
on 2024/05/19 14:30
on 2024/05/19 14:30
Change comment:
There is no comment for this version
To version 11.1
edited by Alexandru Pentilescu
on 2024/05/19 14:43
on 2024/05/19 14:43
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -195,7 +195,36 @@ 195 195 196 196 Note, you need sudo privileges to read the mail.log file, as it is owned by the syslog user and it has restricted reading privileges. 197 197 198 += Opening up port 587 for SMTP traffic = 199 +Certain services refuse to accept STARTTLS traffic on port 25, as is open, by default, on Postfix (looking at you, Gitea). To account for them, we must open port 587 to attain this. To do so, we must open the master.cf configuration file (mine was under "/etc/postfix/master.cf") and add the following line: 198 198 201 +{{code}} 202 +smtp inet n - y - - smtpd 203 +587 inet n - n - - smtpd 204 +{{/code}} 205 + 206 +The smtp line was already there. I only added the 587 line. This instructs Postfix to bind itself to the 587 port, such that, any services wanting to reach that port in order to start a STARTTLS connection, wil be able to do so. 207 + 208 +Once this is done, restart the Postfix daemon with a systemctl restart command and everything should almost be done. Almost. 209 + 210 +Ubuntu server also comes preinstalled with a firewall utility that will deny traffic towards its own port 587. This can be an impediment. As such, please allow traffic from your docker containers to be able to reach this port: 211 + 212 +{{code language="bash"}} 213 +sudo ufw allow from 172.16.0.0/16 to any port 587 214 +{{/code}} 215 + 216 +If you recall from above, 172.16.0.0/16 was the IP range we configured for our docker engine to use when assigning IPs to its container networks. So that command will effectively allow all traffic originating from docker containers to be explicitly allowed to reach the host's own 587 port, to be able to initiate a STARTTLS encrypted channel. 217 + 218 +While you're on it, you may also do 219 + 220 +{{code language="bash"}} 221 +sudo ufw status numbered 222 +sudo ufw delete <rule number for opening port 25> 223 +{{/code}} 224 + 225 +to delete the firewall rules that allow full access to port 25. This solved an issue where Google would spam my Gmail inbox with unnecessary garbage because it was trying to relay bounced email notifications to me, which was highly annoying to say the least. 226 + 227 +Please note, though, that 199 199 = Wrapping it up= 200 200 That's it! As soon as you finish editing the main configuration file, please remember to restart the Postfix service afterwards so that the changes can take effect immediately (or reboot the machine). 201 201