Changes for page How to setup a postfix SMTP server
Last modified by Alexandru Pentilescu on 2025/02/09 14:17
From version 13.1
edited by Alexandru Pentilescu
on 2024/07/02 20:17
on 2024/07/02 20:17
Change comment:
There is no comment for this version
To version 15.1
edited by Alexandru Pentilescu
on 2025/02/09 14:17
on 2025/02/09 14:17
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -163,6 +163,16 @@ 163 163 postmap /etc/postfix/config 164 164 {{/code}} 165 165 166 +Afterwards, you will be required to also edit the "/etc/postfix/master.cf" file, to enable postfix to open up its own 587 port. To do so, open this file in read-write mode and uncomment the following lines: 167 + 168 +{{code language="ini"}} 169 +submission inet n - y - - smtpd 170 + -o syslog_name=postfix/submission 171 + -o smtpd_tls_security_level=encrypt 172 + -o smtpd_sasl_auth_enable=yes 173 + -o smtpd_tls_auth_only=yes 174 +{{/code}} 175 + 166 166 Once this is configured and ready to go, you can safely restart the postfix service and rely on Google to relay your emails for you. 167 167 168 168 = Configuring the Postfix service such that it always restarts when the system is running low on RAM = ... ... @@ -180,16 +180,22 @@ 180 180 {{code language="Systemd"}} 181 181 [Unit] 182 182 Description=Postfix Mail Transport Agent 183 - Conflicts=sendmail.service exim4.service184 - ConditionPathExists=/etc/postfix/main.cf193 +After=network-online.target docker.service 194 +Wants=network-online.target 185 185 186 186 [Service] 187 -Type=oneshot 188 -RemainAfterExit=yes 189 -ExecStart=/bin/true 190 -ExecReload=/bin/true 191 -Restart=on-failure 192 -RestartSec=1s 197 +Type=forking 198 +ExecStart=/usr/sbin/postfix start 199 +ExecStop=/usr/sbin/postfix stop 200 +ExecReload=/usr/sbin/postfix reload 201 +Restart=always 202 +RestartSec=5s 203 +ExecStartPre=/bin/sleep 10 204 +PIDFile=/var/spool/postfix/pid/master.pid 205 + 206 +[Install] 207 +WantedBy=multi-user.target 208 + 193 193 {{/code}} 194 194 195 195 From that, the only genuinely relevant changes that need to be highlighted are the last two lines (i.e. the "Restart" and "RestartSec" assignments). These tell systemd that that, in the event that the service gets killed due to an abnormality (i.e. it receives a SIGKILL system because it is running low on RAM), to automatically restart it. The second rule (i.e. "RestartSec"), tells it to wait an entire second before performing the restart, so that it gives the system the chance to finish whatever it was doing.