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

    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:

    sudo mkdir /var/log/spamassassin
    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



    6. Now, we just need to connect it up to PostFix. Edit /etc/postfix/master.cf. First, find this line:

        smtp inet n - - - - smtpd

        And add this line immediately underneath:

        -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 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:

Comments

Popular posts from this blog

Sync iTunes with MythMusic

Using Homebridge and Broadlink RM Mini to automate

LetsEncrypt and AWS ELB Load Balancers