Spam Control

Hi i am little bit confuse about SpamAssassin about below line
Smtp inet n - n - - smtpd When i insert that line mail work but spam not work

and when i insert
spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Mail not coming which line work better

Please help me

The first line is amended if it’s not already to show like
smtp inet n - n - - smtpd -o content_filter=spamassassin

then at the bottom is where the second line goes.
spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Here’s an example of the full file. Note line number 11 and 130

then after
service postfix restart

check its working

Just in case anyone else runs into this on Centos7 OpenVZ

Seems the default install does not work at least on the OP one which we finally got working.

If you get this message but are not seeing the email in the inbox and permissions and everything else is right:
delivered via spamassassin service)

Open config file and change the below line
nano /etc/postfix/master.cf

From:
spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

To:
spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

If this is on Ubuntu and your getting that error the line might need to be using the Ubuntu lib path of /usr/lib/dovecot/deliver
spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

service dovecot restart && service postfix restart && service spamassassin restart;
service dovecot status && service postfix status && service spamassassin status;

Hopefully, that fixes the issue.

Optional things that might be needed that we did try during debugging.

If you get this error:
spamc[7957]: connect to spamd on ::1 failed, retrying (#1 of 3): Connection refused

Disable IPv6:
Append below lines in /etc/sysctl.conf:
nano /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

To make the settings affective, execute :
sysctl -p

Add missing spamd user:
groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
chown spamd:spamd /var/log/spamassassin
service spamassassin restart

Create this file with the below value to ensure spamd listening on localhost
[root@srv ~]# cat /etc/mail/spamassassin/spamc.conf
-d 127.0.0.1
[root@srv ~]#

Thanks whattheserver this notes lot of work me

I have ubuntu and new to cyberpanel, I have the settings in order that deletes the spam directly from server

required_hits 5.0
report_safe 1
rewrite_header Subject [SPAM]
required_score 5

however the messages marked as spam are coming to my inbox,any solution

Type your comment> @whattheserver said:

Just in case anyone else runs into this on Centos7 OpenVZ

Seems the default install does not work at least on the OP one which we finally got working.

If you get this message but are not seeing the email in the inbox and permissions and everything else is right:
delivered via spamassassin service)

Open config file and change the below line
nano /etc/postfix/master.cf

From:
spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

To:
spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

If this is on Ubuntu and your getting that error the line might need to be using the Ubuntu lib path of /usr/lib/dovecot/deliver
spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

service dovecot restart && service postfix restart && service spamassassin restart;
service dovecot status && service postfix status && service spamassassin status;

Hopefully, that fixes the issue.

Optional things that might be needed that we did try during debugging.

If you get this error:
spamc[7957]: connect to spamd on ::1 failed, retrying (#1 of 3): Connection refused

Disable IPv6:
Append below lines in /etc/sysctl.conf:
nano /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

To make the settings affective, execute :
sysctl -p

Add missing spamd user:
groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
chown spamd:spamd /var/log/spamassassin
service spamassassin restart

Create this file with the below value to ensure spamd listening on localhost
[root@srv ~]# cat /etc/mail/spamassassin/spamc.conf
-d 127.0.0.1
[root@srv ~]#

I had the same spamd error in my stock CentOS 8 image. You will need to ensure with future CyberPanel releases that the following is in sysctl.conf. This comes from this post above.


If you get this error:
spamc[7957]: connect to spamd on ::1 failed, retrying (#1 of 3): Connection refused

Disable IPv6:
Append below lines in /etc/sysctl.conf:
nano /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

To make the settings affective, execute :
sysctl -p


My CentOS 8’s sysct.conf already had net.ipv6.conf.all.disable_ipv6 = 1, but was missing net.ipv6.conf.default.disable_ipv6 = 1. You may want to add a check for this in future CyberPanel release because it was causing my emails to take about 6 minutes to get received and delivered from the time they were sent by the sending server.

I don’t post for post count or to promote my signature. If that is your implication I can remove my signature and still say exactly the same.

I understand you do this on a voluntary basis and users including myself are extremely grateful when you proactively contribute. However, it is like trying to squeeze blood out of a turnip when you say more or less “oh, but it works on my setup” in many threads and you effectively shut the door on the conversation when you do. The point often is that it doesn’t work on other people’s setups in many circumstances, and your telling us your setup works doesn’t make our setups work.

The actual solution requires some fine-tuning, maybe even a mere line of code being tweaked to suit the circumstance, and it also requires some back and forth in conversation. Asking clarifying questions like “What VPS host are you running it on?” or “Can you provide me some IP configuration information by running the following command?” would go a long way to remediate.

Now, I understand you want to help and that is commendable, but such default responses can come off like you are on the defensive and you just want to prove that you are right. I also understand that it can be tiring at times when users miss what you may think is something so basic. But we are not experts in everything and that includes technical professionals like myself who do hosting as a hobby.

Believe it or not, Einstein had no idea what a beans plant was when a fellow physicist showed it to him, meaning Einstein did not know beans! At the end of the day, even if you are doing this as a volunteer service (and thank you again for it), you still have to point people in the right direction. We do not know what you are thinking in your head–we aren’t mind readers, after all–so a little engagement would do wonders.