Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Mailcow - Speed Up SMTP Sending With IP Whitelist

After having deployed Mailcow, I couldn't help but notice that sending emails was noticeably slower. This made it feel like my website's were "broken" as they became unresponsonsive on any actions that are sending email notifications in the background. Luckily this is easily resolved through adding one's website's IP addresses to the IP whitelist.

Steps

SSH into your mailcow server and go to whichever directory you set it up in. For me this was:

cd $HOME/mailcow-dockerized

Then navigate to the postfix configuration subdirectory:

cd data/conf/postfix

Then edit the custom_postscreen_whitelist.cidr file:

sudo editor custom_postscreen_whitelist.cidr

The file will look like as follows by default:

# Autogenerated by mailcow
# Rules are evaluated in the order as specified.
# Blacklist 192.168.* except 192.168.0.1.
# 192.168.0.1          permit
# 192.168.0.0/16       reject

Simply append a line for each of your server's IP addresses. E.g.

# Autogenerated by mailcow
# Rules are evaluated in the order as specified.
# Blacklist 192.168.* except 192.168.0.1.
# 192.168.0.1          permit
# 192.168.0.0/16       reject

# server1
xxx.yyy.zzz.xyz/32        permit

# www.mywebsite.com
xxx.yyy.zzz.xyz/32        permit

Replace xx.yy.zz.xyz with your server's IP address.

Then save and exit.

The changes should have immediate effect with no need to restart any services.

References

Last updated: 29th November 2024
First published: 29th November 2024