Faruque Ahmed : MCP, MCSA, MCSE, MCTS, MCIT, CCNA, OCA, OCP, GCP
root@mail:~# apt-get -y install dovecot-core dovecot-pop3d dovecot-imapd dovecot-lmtpd
Dovecot code Check# doveconf -n# doveconf -h[root@mail ~]# dovecot -F
root@mail:~# vi /etc/dovecot/dovecot.conf
Instruction 1: !include_try local.conf
Instruction 2: protocols = pop3 pop3s imap
# line 30 : uncomment
listen = *, ::
root@mail:~# vi /etc/dovecot/conf.d/10-auth.conf
# line 10 : uncomment and change (allow plain text auth)
disable_plaintext_auth = no
# line 100 : add
auth_mechanisms = plain login
root@mail:~# vi /etc/dovecot/conf.d/10-mail.conf
# line 30 : change to Maildir
mail_location = maildir:~/Maildir
root@mail:~# vi /etc/dovecot/conf.d/10-master.conf
# line 110-112 : uncomment and add
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix}
--------------------------------------------------
Enable protocols
Open # vi /etc/dovecot/conf.d/20-imap.conf and # vi /etc/dovecot/conf.d/20-pop3.conf and verify:
protocols = imap pop3
root@mail:~# systemctl restart dovecot
Mar 24 09:06:05 mail dovecot: imap(habib1@worldcm.net): Fatal: master: service(imap): child 4736 returned error 83 (Out of memory (service imap { vsz_limit=256 MB }, you may need to increase it) - set CORE_OUTOFMEM=1 environment to get core dump)
# vi /etc/dovecot/conf.d/10-master.conf
Update the package lists and install Postfix, Dovecot, SpamAssassin, and spamc:
sudo apt update#
apt-get install postfix dovecot-imapd dovecot-pop3d spamassassin spamc
Enable the SpamAssassin service to start automatically at boot, and then start the service:
systemctl enable spamassassin
systemctl start spamassassin
Edit the SpamAssassin configuration file /etc/spamassassin/local.cf using a text editor (e.g., nano or vim):
vi /etc/spamassassin/local.cf
Add or modify the following settings in the file:
These settings will mark emails with a spam score of 5.0 or higher by adding "[SPAM]" to the subject. You can adjust the required_score value as needed. Save the changes and exit the editor.
Edit the Postfix configuration file /etc/postfix/master.cf:
vi /etc/postfix/master.cf
Add the following lines to the end of the file:
Save the changes and exit the editor.
Restart the Postfix service to apply the changes:
systemctl restart postfix
Edit the Dovecot configuration file /etc/dovecot/conf.d/90-sieve.conf:
# nano /etc/dovecot/conf.d/90-sieve.conf
Uncomment or add the following lines:
Save the changes and exit the editor.
Create a default Sieve script /etc/dovecot/sieve/default.sieve:
# nano /etc/dovecot/sieve/default.sieve
Add the following content to the file:
This script will automatically move messages marked as spam to the "Junk" folder. Save the changes and exit the editor.
Compile the Sieve script:
sievec /etc/dovecot/sieve/default.sieve
systemctl restart dovecot
SpamAssassin will now automatically process incoming emails on your server and mark them as spam based on your configuration. The Dovecot Sieve script will move the messages marked as spam to the "Junk" folder for each user. You can further refine the configuration by editing /etc/spamassassin/local.cf and adjusting the settings as needed.