Setup your own email server (MTA) on the cheap - part 3
Now we’ve got everything working with our MTA, we need to lock it down. If you’re redirecting SPAM to Gmail there’s a risk that they’ll identify you as a SPAMMER and blacklist your IP address. To reduce this risk, we’ll install SpamAssassin to filter messages before we forward them.
1. First, install SpamAssassin
sudo apt-get install spamassassin
And its requirements:
sudo apt-get install libmail-dkim-perl libcrypt-openssl-random-perl libcrypt-openssl-rsa-perl
sudo mkdir /var/log/spamassassin
6. Now, we just need to connect it up to PostFix. Edit /etc/postfix/master.cf. First, find this line:
-o content_filter=spamassassin
Now scroll to the bottom of /etc/postfix/master.cf and add these lines:
7. Now, just restart the services and you’re set:
sudo systemctl restart postfix.service
sudo apt-get install spamassassin
And its requirements:
2. Setup a user and group for the daemons:
sudo groupadd spamd
sudo useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
3. Setup a folder for the logs:
3. Setup a folder for the logs:
sudo chown spamd:spamd /var/log/spamassassin
4. Now, the fun starts. Update the configuration. First, edit /etc/spamassassin/local.cf. you can have some fun tweaking things here but these are the settings I change, and they work well for me:
5. Configure some options for the Daemon – where logs go, which account it runs as.
Edit /etc/default/spamassassin
5. Configure some options for the Daemon – where logs go, which account it runs as.
Edit /etc/default/spamassassin
smtp inet n - - - - smtpd
And add this line immediately underneath:
Now scroll to the bottom of /etc/postfix/master.cf and add these lines:
7. Now, just restart the services and you’re set:
sudo systemctl restart postfix.service
sudo systemctl enable spamassassin.service
sudo systemctl start spamassassin.service
And that’s it. Now if you scan the headers of any messages that pass through this server you should see some information from SpamAssassin under X-Spam.
Big thanks to these sources:
And that’s it. Now if you scan the headers of any messages that pass through this server you should see some information from SpamAssassin under X-Spam.
Big thanks to these sources:
https://www.geoffstratton.com/spamassassin-3-ubuntu-16
Setup Steps with links:
Setup Steps with links:
- Setup PostFix with email address forwarding
- Setup sending and use LetsEncrypt to secure the SMTP server
- > Setup SPAMAssassain so Gmail or Yahoo don’tblock us for passing on dodgy emails
- Setup ClamAV to block viruses, these will get you blocked too
- Setup DKIM using opendkim to check DKIM on incoming and sign our outgoing mail
- Update sender addresses so SPF passes for forwarded messages
- Use Fail2Ban to block brute force attempts on our server
Comments