{"id":9425,"date":"2024-10-12T12:09:18","date_gmt":"2024-10-12T12:09:18","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=9425"},"modified":"2024-10-14T17:32:47","modified_gmt":"2024-10-14T17:32:47","slug":"how-to-install-and-configure-spamassassin-on-ubuntu-and-centos","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/","title":{"rendered":"How to install and configure SpamAssassin on Ubuntu and CentOS"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en.jpg\" alt=\"Configure SpamAssassin on Ubuntu and CentOS\" class=\"wp-image-9440\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>Spam email is a common nuisance that not only clutters your inbox but can also introduce security risks. Thankfully, there are powerful tools available to help combat the flood of unwanted messages. One of the most effective anti-spam tools for Linux-based systems is&nbsp;<strong>SpamAssassin<\/strong>. In this comprehensive guide, we will walk you through the steps required to configure SpamAssassin on both&nbsp;<strong>Ubuntu<\/strong>&nbsp;and&nbsp;<strong>CentOS<\/strong>.<\/p>\n\n\n\n<p>Whether you&#8217;re a system administrator setting up a mail server for the first time or an experienced professional optimizing your current setup, this guide will help you implement a robust anti-spam solution on your server. We\u2019ll cover everything from installation to advanced configurations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p>Email spam is a persistent issue that affects both individuals and organizations. For system administrators, managing spam efficiently is crucial to maintaining the integrity and security of their mail servers. This is where\u00a0SpamAssassin\u00a0comes into play. SpamAssassin is a highly configurable and widely used open-source spam filter. It uses a variety of techniques including blacklists, keyword scanning, and machine learning to detect and eliminate spam.<\/p>\n\n\n\n<p>In this tutorial, we&#8217;ll explore how to configure\u00a0SpamAssassin\u00a0on both Ubuntu and CentOS. The two operating systems may require slightly different configurations, but the core principles remain the same.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-use-spamassassin\"><strong>Why Use SpamAssassin?<\/strong><\/h3>\n\n\n\n<p>SpamAssassin is renowned for its powerful and flexible spam filtering capabilities. Here are some key benefits:<\/p>\n\n\n\n<ul>\n<li><strong>Open Source<\/strong>: It\u2019s free to use and continuously updated by a large community of developers.<\/li>\n\n\n\n<li><strong>Customizable<\/strong>: You can fine-tune its settings to meet your specific requirements.<\/li>\n\n\n\n<li><strong>Scalable<\/strong>: Works for small personal mail servers as well as large enterprise environments.<\/li>\n\n\n\n<li><strong>Multi-technique Approach<\/strong>: Combines multiple spam detection techniques including pattern matching, Bayesian filtering, and real-time blacklists.<\/li>\n\n\n\n<li><strong>Integration<\/strong>: Works well with popular mail transfer agents (MTAs) like Postfix, Exim, and Sendmail.<\/li>\n<\/ul>\n\n\n\n<p>SpamAssassin significantly reduces the risk of your mail server being overwhelmed by spam while keeping false positives to a minimum.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p>Before we get started with the installation and configuration of SpamAssassin, ensure that your server meets the following prerequisites:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"system-requirements\"><strong>System Requirements<\/strong><\/h3>\n\n\n\n<ul>\n<li><strong>Operating Systems<\/strong>: Ubuntu 18.04\/20.04\/22.04, CentOS 7\/8\/Stream<\/li>\n\n\n\n<li><strong>Root or Sudo Privileges<\/strong>: You will need root access to install packages and make system-wide changes.<\/li>\n\n\n\n<li><strong>Installed Mail Transfer Agent (MTA)<\/strong>: Postfix, Exim, or another MTA of your choice.<\/li>\n\n\n\n<li><strong>Internet Connection<\/strong>: Required to download and install packages.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-on-ubuntu\"><strong>Installation on Ubuntu<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-dependencies\"><strong>Installing Dependencies<\/strong><\/h3>\n\n\n\n<p>Before installing SpamAssassin, make sure your system is up-to-date by running the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt update\n$ sudo apt upgrade<\/code><\/pre>\n\n\n\n<p>Next, install SpamAssassin and its dependencies:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt install spamassassin spamc<\/code><\/pre>\n\n\n\n<p>This command will install SpamAssassin (<code>spamassassin<\/code>) and&nbsp;<code>spamc<\/code>, the client-side tool that communicates with SpamAssassin\u2019s daemon.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuration-on-ubuntu\"><strong>Configuration on Ubuntu<\/strong><\/h2>\n\n\n\n<p>After the installation is complete, you need to configure SpamAssassin to tailor it to your needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"editing-the-configuration-file\"><strong>Editing the Configuration File<\/strong><\/h3>\n\n\n\n<p>SpamAssassin&#8217;s primary configuration file is located at&nbsp;<code>\/etc\/spamassassin\/local.cf<\/code>. Open it for editing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo nano \/etc\/spamassassin\/local.cf<\/code><\/pre>\n\n\n\n<p>Here are some important configuration options:<\/p>\n\n\n\n<ul>\n<li><strong>Required Hits<\/strong>: This sets the threshold score for classifying an email as spam. The default is 5, but you can lower it for more aggressive filtering:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">required_score 4.0<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>Report Safe<\/strong>: If set to 1, SpamAssassin will encapsulate spam messages in an attachment. If set to 0, it will modify the subject line:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">report_safe 0<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>Rewrite Subject<\/strong>: This modifies the subject line of emails marked as spam. By default, it&#8217;s commented out, but you can activate it:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">rewrite_header Subject *****SPAM*****<\/code><\/pre>\n\n\n\n<p>After making the necessary changes, save the file and exit the editor.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"starting-and-enabling-spamassassin\"><strong>Starting and Enabling SpamAssassin<\/strong><\/h2>\n\n\n\n<p>To run SpamAssassin as a daemon, we need to modify the system service settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"enabling-the-daemon\"><strong>Enabling the Daemon<\/strong><\/h3>\n\n\n\n<p>Edit the file&nbsp;<code>\/etc\/default\/spamassassin<\/code>&nbsp;to ensure that the daemon starts on boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo nano \/etc\/default\/spamassassin<\/code><\/pre>\n\n\n\n<p>Change the following lines to look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">ENABLED=1\nOPTIONS=\"--create-prefs --max-children 5 --helper-home-dir\"\nCRON=1<\/code><\/pre>\n\n\n\n<p>This ensures that SpamAssassin runs as a background service.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"starting-the-service\"><strong>Starting the Service<\/strong><\/h3>\n\n\n\n<p>Enable and start the SpamAssassin service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo systemctl enable spamassassin\n$ sudo systemctl start spamassassin<\/code><\/pre>\n\n\n\n<p>You can verify that SpamAssassin is running using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo systemctl status spamassassin<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"testing-the-installation\"><strong>Testing the Installation<\/strong><\/h3>\n\n\n\n<p>Send a test email through your MTA to verify that SpamAssassin is working correctly. You can check the mail headers to see if SpamAssassin has added any spam-related headers.<\/p>\n\n\n\n<p>Alternatively, you can use&nbsp;<code>spamc<\/code>&nbsp;to test the filtering:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ echo \"Test message\" | spamc<\/code><\/pre>\n\n\n\n<p>SpamAssassin will process the message and output the spam score.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-on-centos\"><strong>Installation on CentOS<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-spamassassin-on-centos\"><strong>Installing SpamAssassin on CentOS<\/strong><\/h3>\n\n\n\n<p>On CentOS, the process is similar but uses&nbsp;<code>yum<\/code>&nbsp;or&nbsp;<code>dnf<\/code>&nbsp;package managers. First, ensure your system is up-to-date:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum update<\/code><\/pre>\n\n\n\n<p>Then install SpamAssassin using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum install spamassassin<\/code><\/pre>\n\n\n\n<p>For CentOS 8 or Stream, you may use&nbsp;<code>dnf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo dnf install spamassassin<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuration-on-centos\"><strong>Configuration on CentOS<\/strong><\/h2>\n\n\n\n<p>The configuration process is similar to Ubuntu, with SpamAssassin&#8217;s configuration file located at&nbsp;<code>\/etc\/mail\/spamassassin\/local.cf<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"adjusting-configuration-files\"><strong>Adjusting Configuration Files<\/strong><\/h3>\n\n\n\n<p>Open the&nbsp;<code>local.cf<\/code>&nbsp;file to configure SpamAssassin settings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo nano \/etc\/mail\/spamassassin\/local.cf<\/code><\/pre>\n\n\n\n<p>Make adjustments based on your needs:<\/p>\n\n\n\n<ul>\n<li><strong>required_score<\/strong>: Similar to Ubuntu, adjust the spam score threshold:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">required_score 4.0<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>rewrite_header<\/strong>: Modify the subject line of spam emails:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">rewrite_header Subject *****SPAM*****<\/code><\/pre>\n\n\n\n<p>Save and exit the file once you&#8217;re done.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"running-spamassassin-on-centos\"><strong>Running SpamAssassin on CentOS<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"enabling-and-starting-the-daemon\"><strong>Enabling and Starting the Daemon<\/strong><\/h3>\n\n\n\n<p>To ensure SpamAssassin starts at boot, edit the system configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo nano \/etc\/sysconfig\/spamassassin<\/code><\/pre>\n\n\n\n<p>Look for the line that says&nbsp;<code>ENABLED=0<\/code>&nbsp;and change it to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">ENABLED=1<\/code><\/pre>\n\n\n\n<p>Save and close the file. Then enable and start SpamAssassin:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo systemctl enable spamassassin\n$ sudo systemctl start spamassassin<\/code><\/pre>\n\n\n\n<p>Check the status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo systemctl status spamassassin<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"testing-and-verifying-the-setup\"><strong>Testing and Verifying the Setup<\/strong><\/h3>\n\n\n\n<p>To test your setup, use&nbsp;<code>spamc<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ echo \"Test email content\" | spamc<\/code><\/pre>\n\n\n\n<p>Verify that SpamAssassin processes the email and outputs a spam score.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"advanced-configuration\"><strong>Advanced Configuration<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bayesian-filtering\"><strong>Bayesian Filtering<\/strong><\/h3>\n\n\n\n<p>SpamAssassin uses Bayesian filtering to learn from the spam and ham (non-spam) messages that pass through the system. To enable Bayesian filtering, open the&nbsp;<code>local.cf<\/code>&nbsp;configuration file and add:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">use_bayes 1\nbayes_auto_learn 1<\/code><\/pre>\n\n\n\n<p>This will automatically update the Bayesian database as emails are processed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"enabling-spf-and-dkim-checks\"><strong>Enabling SPF and DKIM Checks<\/strong><\/h3>\n\n\n\n<p>To improve the accuracy of spam detection, you can enable&nbsp;<strong>SPF<\/strong>&nbsp;(Sender Policy Framework) and&nbsp;<strong>DKIM<\/strong>&nbsp;(DomainKeys Identified Mail) checks.<\/p>\n\n\n\n<ul>\n<li><strong>SPF<\/strong>: Add the following line to your configuration:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">use_spf 1<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>DKIM<\/strong>: Install&nbsp;<code>Mail::DKIM<\/code>&nbsp;on your system and add this to&nbsp;<code>local.cf<\/code>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">loadplugin Mail::SpamAssassin::Plugin::DKIM<\/code><\/pre>\n\n\n\n<p>These techniques help verify the authenticity of the email sender and reduce false positives.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"integration-with-mail-servers\"><strong>Integration with Mail Servers<\/strong><\/h2>\n\n\n\n<p>SpamAssassin can be integrated with popular mail transfer agents like Postfix and Exim for real-time spam filtering.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"integrating-with-postfix\"><strong>Integrating with Postfix<\/strong><\/h3>\n\n\n\n<p>To integrate SpamAssassin with&nbsp;<strong>Postfix<\/strong>, you\u2019ll need to configure&nbsp;<strong>Postfix<\/strong>&nbsp;to pass incoming mail through&nbsp;<strong>SpamAssassin<\/strong>.<\/p>\n\n\n\n<p>Edit the Postfix configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo nano \/etc\/postfix\/master.cf<\/code><\/pre>\n\n\n\n<p>Add the following lines to the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">spamassassin unix - n n - - pipe\n  user=spamassassin argv=\/usr\/bin\/spamc -f -e\n  \/usr\/sbin\/sendmail -oi -f ${sender} ${recipient}<\/code><\/pre>\n\n\n\n<p>This configuration ensures that Postfix forwards incoming emails to SpamAssassin for processing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"automating-spam-filtering\"><strong>Automating Spam Filtering<\/strong><\/h3>\n\n\n\n<p>You can automate the process of updating SpamAssassin\u2019s rules using cron jobs. This ensures that your spam filters remain up-to-date.<\/p>\n\n\n\n<p>Create a cron job to update SpamAssassin\u2019s rules periodically:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo crontab -e<\/code><\/pre>\n\n\n\n<p>Add the following line to run a nightly update:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">0 3 * * * \/usr\/bin\/sa-update &amp;&amp; \/usr\/bin\/systemctl restart spamassassin<\/code><\/pre>\n\n\n\n<p>This will update the rules at 3 AM every day and restart the SpamAssassin service to apply the changes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"optimizing-spamassassin\"><strong>Optimizing SpamAssassin<\/strong><\/h2>\n\n\n\n<p>SpamAssassin can be resource-intensive, especially on high-traffic mail servers. Here are some tips to optimize its performance:<\/p>\n\n\n\n<ul>\n<li><strong>Limit Child Processes<\/strong>: Edit the&nbsp;<code>local.cf<\/code>&nbsp;file and reduce the number of child processes:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"properties\" class=\"language-properties\">max_children 2<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>Use SpamD<\/strong>: Running SpamAssassin as a daemon (<code>spamd<\/code>) can significantly reduce the resource overhead.<\/li>\n\n\n\n<li><strong>Whitelist Known Good Senders<\/strong>: You can whitelist trusted senders to bypass spam filtering. Add them to&nbsp;<code>\/etc\/spamassassin\/local.cf<\/code>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"properties\" class=\"language-properties\">whitelist_from *@example.com<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"logging-and-monitoring\"><strong>Logging and Monitoring<\/strong><\/h2>\n\n\n\n<p>Checking logs regularly helps you identify potential issues and ensure SpamAssassin is functioning correctly. Logs are stored in&nbsp;<code>\/var\/log\/maillog<\/code>&nbsp;or&nbsp;<code>\/var\/log\/mail.log<\/code>.<\/p>\n\n\n\n<p>To view the logs, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tail -f \/var\/log\/mail.log<\/code><\/pre>\n\n\n\n<p>This will display real-time updates as mail is processed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"troubleshooting\"><strong>Troubleshooting<\/strong><\/h2>\n\n\n\n<p>Here are some common issues you may encounter while configuring SpamAssassin:<\/p>\n\n\n\n<ul>\n<li><strong>SpamAssassin Not Starting<\/strong>: Check the system logs for errors and ensure the configuration files are correct.<\/li>\n\n\n\n<li><strong>High False Positive Rate<\/strong>: Adjust the&nbsp;<code>required_score<\/code>&nbsp;to reduce the aggressiveness of the spam filter.<\/li>\n\n\n\n<li><strong>SpamAssassin Not Processing Emails<\/strong>: Verify that your MTA is correctly configured to forward emails to SpamAssassin.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faqs\"><strong>FAQs<\/strong><\/h2>\n\n\n\n<p><strong>How does SpamAssassin detect spam?<\/strong><br>SpamAssassin uses a variety of techniques including pattern matching, Bayesian filtering, blacklists, and DNS-based checks to detect spam.<\/p>\n\n\n\n<p><strong>Can SpamAssassin be used with any mail server?<\/strong><br>Yes, SpamAssassin can be integrated with popular mail servers like Postfix, Exim, and Sendmail.<\/p>\n\n\n\n<p><strong>How can I reduce false positives?<\/strong><br>You can adjust the&nbsp;<code>required_score<\/code>&nbsp;and whitelist trusted senders to reduce the chances of legitimate emails being marked as spam.<\/p>\n\n\n\n<p><strong>Is SpamAssassin resource-intensive?<\/strong><br>SpamAssassin can be resource-intensive, especially on large mail servers. However, using optimizations like limiting child processes and running it as a daemon can help.<\/p>\n\n\n\n<p><strong>What are the key configuration files for SpamAssassin?<\/strong><br>The main configuration file is&nbsp;<code>\/etc\/spamassassin\/local.cf<\/code>. You may also need to modify the MTA configuration file to integrate SpamAssassin.<\/p>\n\n\n\n<p><strong>Can I update SpamAssassin\u2019s rules automatically?<\/strong><br>Yes, you can set up a cron job to update SpamAssassin\u2019s rules using the&nbsp;<code>sa-update<\/code>&nbsp;command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Configuring SpamAssassin on Ubuntu and CentOS is a relatively straightforward process that can dramatically reduce the amount of spam reaching your inbox. By following the steps outlined in this tutorial, you can install, configure, and optimize SpamAssassin for your mail server, ensuring effective spam filtering with minimal false positives. With advanced features like Bayesian filtering, SPF, and DKIM support, SpamAssassin is a powerful tool in the fight against spam.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spam email is a common nuisance that not only clutters your inbox but can also introduce security risks. Thankfully, there are powerful tools available to help combat the flood of unwanted messages. One of the most effective anti-spam tools for Linux-based systems is&nbsp;SpamAssassin. In this comprehensive guide, we will walk you through the steps required ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[69,277],"tags":[],"yoast_head":"\n<title>How to install and configure SpamAssassin on Ubuntu and CentOS - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Learn how to configure SpamAssassin on Ubuntu and CentOS with this detailed step-by-step guide. Block spam efficiently on your mail server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install and configure SpamAssassin on Ubuntu and CentOS - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Learn how to configure SpamAssassin on Ubuntu and CentOS with this detailed step-by-step guide. Block spam efficiently on your mail server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-12T12:09:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-14T17:32:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"How to install and configure SpamAssassin on Ubuntu and CentOS\",\"datePublished\":\"2024-10-12T12:09:18+00:00\",\"dateModified\":\"2024-10-14T17:32:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\"},\"wordCount\":1466,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"Linux system administration\",\"Mail Servers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\",\"name\":\"How to install and configure SpamAssassin on Ubuntu and CentOS - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2024-10-12T12:09:18+00:00\",\"dateModified\":\"2024-10-14T17:32:47+00:00\",\"description\":\"Learn how to configure SpamAssassin on Ubuntu and CentOS with this detailed step-by-step guide. Block spam efficiently on your mail server.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install and configure SpamAssassin on Ubuntu and CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1783634435\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1783634435\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"How to install and configure SpamAssassin on Ubuntu and CentOS - WebHi Tutorials &amp; Documentations","description":"Learn how to configure SpamAssassin on Ubuntu and CentOS with this detailed step-by-step guide. Block spam efficiently on your mail server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/","og_locale":"en_US","og_type":"article","og_title":"How to install and configure SpamAssassin on Ubuntu and CentOS - WebHi Tutorials &amp; Documentations","og_description":"Learn how to configure SpamAssassin on Ubuntu and CentOS with this detailed step-by-step guide. Block spam efficiently on your mail server.","og_url":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2024-10-12T12:09:18+00:00","article_modified_time":"2024-10-14T17:32:47+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/10\/spam_assassin_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"How to install and configure SpamAssassin on Ubuntu and CentOS","datePublished":"2024-10-12T12:09:18+00:00","dateModified":"2024-10-14T17:32:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/"},"wordCount":1466,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["Linux system administration","Mail Servers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/","url":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/","name":"How to install and configure SpamAssassin on Ubuntu and CentOS - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2024-10-12T12:09:18+00:00","dateModified":"2024-10-14T17:32:47+00:00","description":"Learn how to configure SpamAssassin on Ubuntu and CentOS with this detailed step-by-step guide. Block spam efficiently on your mail server.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-and-configure-spamassassin-on-ubuntu-and-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"How to install and configure SpamAssassin on Ubuntu and CentOS"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1783634435","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1783634435","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/9425"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=9425"}],"version-history":[{"count":6,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/9425\/revisions"}],"predecessor-version":[{"id":9503,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/9425\/revisions\/9503"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=9425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=9425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=9425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}