Linux Mailserver
Anti Spam - Postfix, Amavisd-milter, Spamassain
apt install pyzor clamav-milter dkimpy-milter amavisd-milter postfix-policyd-spf-python
Postfix
Master.cf
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o receive_override_options=no_address_mappings
# SPF check
policyd-spf unix - n n - 0 spawn
user=policyd-spf argv=/usr/bin/policyd-spf
main.cf
smtpd_recipient_restrictions = permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
check_policy_service unix:private/policyd-spf,
reject_unlisted_recipient,
check_sender_access hash:/etc/postfix/sender_access,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
reject_unknown_sender_domain,
reject_non_fqdn_hostname,
reject_unknown_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_invalid_hostname
smtpd_helo_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_invalid_hostname,
reject_unknown_hostname,
reject_non_fqdn_hostname,
reject_unknown_sender_domain,
reject_non_fqdn_sender
smtpd_client_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unknown_client
smtpd_helo_required=yes
content_filter = smtp-amavis:[127.0.0.1]:10024
# SPF check
policyd-spf_time_limit = 3600
/etc/crontab
59 3 * * * root sa-update --allowplugins --channel updates.spamassassin.org; sa-compile
adduser clamav amavis
adduser amavis clamav
razor-admin -create
razor-admin -register
pyzor discover
SPF Check
smtpd_recipient_restrictions =
...
reject_unauth_destination,
check_policy_service unix:private/policyd-spf,
...
OpenDKIM
DMARC
Amavisd-milter
Spamassassin
mysql
create database spamassassin;
CREATE USER 'spamassassin'@'localhost' identified by '**************';
grant CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE on `sogo`.* to 'spamassassin'@'localhost';
FLUSH PRIVILEGES;
exit;
mysql -u root -p spamassassin < /usr/share/doc/spamassassin/sql/bayes_mysql.sql
mysql -u root -p spamassassin < /usr/share/doc/spamassassin/sql/awl_mysql.sql
mysql -u root -p spamassassin < /usr/share/doc/spamassassin/sql/decodeshorturl_mysql.sql
mysql -u root -p spamassassin < /usr/share/doc/spamassassin/sql/txrep_mysql.sql
/usr/bin/sa-learn --spam /home/ok/Maildir/.Junk/cur
/usr/bin/sa-learn --ham /home/ok/Maildir/cur