{"id":5243,"date":"2014-10-24T15:44:17","date_gmt":"2014-10-24T20:44:17","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=5243"},"modified":"2022-12-08T07:57:20","modified_gmt":"2022-12-08T13:57:20","slug":"how-to-install-and-integrate-spamassassin-with-exim-on-a-centos-7-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-and-integrate-spamassassin-with-exim-on-a-centos-7-vps\/","title":{"rendered":"How to install and integrate SpamAssassin with Exim on a CentOS 7 VPS"},"content":{"rendered":"
In the following tutorial we are going to cover the procedure of installing and integrating SpamAssassin with Exim on a CentOS 7 Linux VPS<\/a><\/strong>. Once the set-up is completed, SpamAssassin<\/strong> will be able to scan and mark the emails detected as SPAM.<\/p>\n What is SpamAssassin?<\/strong><\/p>\n It is a software program released under the Apache License 2.0 used for e-mail spam filtering<\/strong> based on content-matching rules. It is a very intelligent email filter<\/strong> which uses a diverse range of tests<\/strong> to identify unsolicited bulk email and apply the tests to email headers and content<\/strong> to classify email using advanced statistical methods.<\/p>\n <\/p>\n <\/p>\n Before proceeding any further, make sure you have a mailserver with Exim<\/strong> setup on your SSD virtual server<\/a>. You can follow our great article on how to setup a mailserver with Exim and Dovecot on a CentOS 7 VPS<\/a> if you don’t have Exim setup already on your Linux VPS<\/a>.<\/p>\n <\/p>\n once you’re in a <\/p>\n SpamAssassin<\/strong> is available in CentOS 7<\/strong> Once it’s installed, edit with all that in place, proceed with starting spamassassin up and adding it to your system’s startup using update spamassassin rules using:<\/p>\n next, check if spamassassin is listening on localhost (127.0.0.1) on port 783 using <\/p>\n OK, next thing to do is to configure Exim to utilize Spamassassin<\/strong> for scanning and tagging unsolicited emails as SPAM. So, make a backup of your current Exim configuration file using:<\/p>\n Next, edit Next, add or uncomment the and add the following within the Next, create the following Exim system filters in and restart Exim for the changes to take effect using:<\/p>\n <\/p>\n To test the setup, simply send a test email with subject <\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install and integrate SpamAssassin with Exim<\/strong>. They are available 24×7 and will take care of your request immediately.<\/p>\n PS<\/span>.<\/strong> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In the following tutorial we are going to cover the procedure of installing and integrating SpamAssassin with Exim on a … <\/p>\nUPDATE THE SYSTEM<\/b><\/h4>\n
ssh<\/code> to your server and initiate a
screen<\/code> session using the command below:<\/p>\n
## screen -U -S exim-spamd<\/pre>\n
screen<\/code> session, update your CentOS 7 VPS<\/a> using
yum<\/code> as in:<\/p>\n
## yum update<\/pre>\n
INSTALL SPAMASSASSIN<\/b><\/h4>\n
base<\/code> repository, so you can easily install it using
yum<\/code>:<\/p>\n
## yum install spamassassin<\/pre>\n
\/etc\/mail\/spamassassin\/local.cf<\/code> using your favorite editor and set the following:<\/p>\n
## vim \/etc\/mail\/spamassassin\/local.cf\r\n\r\nrequired_hits 5\r\nreport_safe 0\r\nrewrite_header Subject [SPAM]\r\nrequired_score 5.0<\/pre>\n
systemctl<\/code><\/p>\n
## systemctl start spamassassin\r\n## systemctl status spamassassin\r\n## systemctl enable spamassassin<\/pre>\n
## sa-update --nogpg<\/pre>\n
ss<\/code> from
iproute2<\/code>:<\/p>\n
## ss -tnlp | grep spamd\r\nLISTEN 0 0 127.0.0.1:783 *:* users:((\"spamd child\",1207,5),(\"spamd child\",1206,5),(\"\/usr\/bin\/spamd \",1205,5))<\/pre>\n
CONFIGURE EXIM WITH SPAMASSASSIN<\/b><\/h4>\n
## cp \/etc\/exim\/exim.conf{,.backup-no-spamd}<\/pre>\n
exim.conf<\/code> and add the following line in the beginning of the file:<\/p>\n
## vim \/etc\/exim\/exim.conf\r\nsystem_filter = \/etc\/exim\/filters\r\n<\/pre>\n
spamd_address<\/code> line as in:<\/p>\n
## vim \/etc\/exim\/exim.conf\r\nspamd_address = 127.0.0.1 783<\/pre>\n
ACLs<\/code> section in your Exim configuration file:<\/p>\n
## vim \/etc\/exim\/exim.conf\r\n\r\n# Bypass SpamAssassin checks if the message is too large.\r\n#\r\naccept condition = ${if >={$message_size}{100000} {1}}\r\n add_header = X-Spam-Note: SpamAssassin run bypassed due to message size\r\n\r\n# Run SpamAssassin, but allow for it to fail or time out. Add a warning message\r\n# and accept the mail if that happens. Add an X-Spam-Flag: header if the SA\r\n# score exceeds the SA system threshold.\r\n#\r\nwarn spam = nobody\/defer_ok\r\n add_header = X-Spam-Flag: YES\r\n add_header = X-Spam-Subject: [SPAM] $h_Subject\r\n\r\naccept condition = ${if !def:spam_score_int {1}}\r\n add_header = X-Spam-Note: SpamAssassin invocation failed\r\n\r\n# Unconditionally add score and report headers\r\n#\r\nwarn add_header = X-Spam-Score: $spam_score ($spam_bar)\\n\\\r\n X-Spam-Report: $spam_report<\/pre>\n
\/etc\/exim\/filters<\/code>:<\/p>\n
## vim \/etc\/exim\/filters\r\nif $h_X-Spam-Flag: contains \"YES\"\r\nthen\r\n headers add \"Old-Subject: $h_subject\"\r\n headers remove \"Subject\"\r\n headers add \"Subject: [SPAM] $h_old-subject\"\r\n headers remove \"Old-Subject\"\r\nendif<\/pre>\n
## systemctl restart exim\r\n## systemctl status exim<\/pre>\n
TEST SPAMASSASSIN<\/b><\/h4>\n
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X<\/code> to any email account available on the mailserver and you should see the following lines in the email header:<\/p>\n
X-Spam-Flag: YES\r\nX-Spam-Subject: [SPAM] XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X\r\nX-Spam-Score: 1000.0 (+++++++++++++++++++++++++++++++++++++++++++++++++++)\r\nX-Spam-Report: Spam detection software, running on the system \"mail.mydomain.com\", has\r\n identified this incoming email as possible spam. The original message\r\n has been attached to this so you can view it (if it isn't spam) or label\r\n similar future email. If you have any questions, see\r\n @@CONTACT_ADDRESS@@ for details.\r\n \r\n Content preview: nov spam email [...] \r\n \r\n Content analysis details: (1000.0 points, 5.0 required)\r\n \r\n pts rule name description\r\n ---- ---------------------- --------------------------------------------------\r\n -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r\n domain\r\n 1000 GTUBE BODY: Generic Test for Unsolicited Bulk Email<\/pre>\n
LET US DO THIS FOR YOU?<\/b><\/h4>\n