gg https://korodes.com/en/rocky_08-2/RockyLinux 8.4 ; Installing a mail server# dnf -y install postfix dovecot cyrus-sasl cyrus-sasl-plain cyrus-sasl-devel# systemctl enable postfix# systemctl enable dovecot# systemctl enable saslauthd# rpm -qa | grep postfixpostfix-2.10.1-7.el7.x86_64# rpm -qa | grep saslcyrus-sasl-plain-2.1.26-23.el7.x86_64cyrus-sasl-lib-2.1.26-23.el7.x86_64cyrus-sasl-devel-2.1.26-23.el7.x86_64cyrus-sasl-md5-2.1.26-23.el7.x86_64 If this is not present # dnf install cyrus-sasl-md5cyrus-sasl-2.1.26-23.el7.x86_64Register Postfix to the service. # systemctl enable postfix.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/postfix.service to/usr/lib/systemd/system/postfix.service.Editing the Postfix Configuration File
①Editing the SMTP Authentication Configuration File
Back up the SMTP authentication configuration file
# cp -p /etc/sasl2/smtpd.conf `date '+ /etc/sasl2/smtpd.conf.%Y%m%d'`# vi /etc/sasl2/smtpd.conf■ Insert "#" at the beginning of the first and second lines, and add the contents# pwcheck_method: saslauthd# mech_list: plain loginpwcheck_method: auxpropauxprop_plugin: sasldbmech_list: cram-md5 digest-md5 plain login➁Registering the saslauthd service # systemctl enable saslauthd.serviceCreated symlink from /etc/systemd/system/multi -user.target.wants/saslauthd.service to/usr/lib/systemd/sy stem/saslauthd.service.# systemctl is-enabled saslauthd.serviceenabled# systemctl start saslauthd.service# dnf -y install --enablerepo=epel spamassassin spamass-milter-postfix# systemctl start spamassassin# systemctl enable spamassassinConfiguring SpamAssassin # vi /etc/mail/spamassassin/v310.pre■Enable the TextCat plugin by removing the # at the beginning of the line per line 24loadplugin Mail::SpamAssassin::Plugin::DCCInstall a script to update the SpamAssassin configuration file. # vi /opt/spamassassin-update.sh#!/bin/bash cd /etc/mail/spamassassinwget -q https://github.com/kittyfreak/spamassassin_user_prefs/archive/refs/heads/main.zip [ $? -ne 0 ] && exit unzip main.zip >/dev/null 2>&1 [ $? -ne 0 ] && exit rm -f main.zip mv spamassassin_user_prefs-main/user_prefs . rm -rf spamassassin_user_prefs-maindiff user_prefs user_prefs.org > /dev/null 2>&1 if [ $? -ne 0 ]; then cp user_prefs local.cf # Do not use attachment format for emails that are judged as spam.echo "report_safe 0" >> local.cf # Add "***SPAM***" to the subject line of emails judged to be spam.echo "rewrite_header Subject ***SPAM***" >> local.cf # Restart SpamAssassinsystemctl restart spamassassin.service > /dev/null fi cp user_prefs user_prefs.orgGrant execute permission to the spamassassin-update script and run it. # chmod 700 /opt/spamassassin-update.sh# /opt/spamassassin-update.shMake sure that the SpamAssassin configuration file is created in the /etc/mail/spamassassin directory on the current date.
directory as of the current date.
# ls -l /etc/mail/spamassassindrwxr-xr-x 2 root root 59 6 月 7 20:02 channel.d-rw-r--r-- 1 root root 1289 10 月16 2018 init.pre-rw-r--r-- 1 root root 486543 9 月 11 20:24 local.cf ←Check that the date is the same as the execution date.drwx------ 2 root root 6 10 月16 2018 sa-update-keys-rw-r--r-- 1 root root 62 10 月16 2018 spamassassin-default.rc⑤Configuring Postfix to incorporate SpamAssassin # vi /etc/postfix/master.cf■Add a "#" to the beginning of the line around line 11 and add SpamAssassin settings on line 12# smtp inet n - n - - smtpdsmtp inet n - n - - smtpd -o content_filter=spamassassin■Add to last linespamassassin unix - n n - - pipeuser=nobody argv=/usr/bin/spamc -e /usr/sbin/sendmail.postfix -oi -f ${sender} ${recipient}gg