Posted by: mahinctg | August 13, 2008

Spamcontrol for Qmail

While using Qmail the biggest problem for me was Messages sent to Non Exsistant User Accounts. Qmail actualy Accept those Messages and then Generates a Mailer Daemon Msg. Most Of the time That Mailer Daemon Msg recided in the Mail Queue and causeing problem as there were huge such mails. I have Solved this Issue with the help from Spamcontrol. (http://www.fehcom.de/qmail/spamcontrol.html). It’s Easy to use also. You Download the Tarball, Patch Qmail and Compile. Then you need some configuration to get your self going. I use 2 features of Spamcontrol, One that checks for Valid Users and another one which checks for Valid Domains which are allowed to send mails via my SMTP. For the First one you need to do the following.

Under /var/qmail/users/ make a file named recipients with all the email ID’s that You accept Mail. Like This

info@xyz.com

noc@xyz.com

info@abc.com

Then run this command to make a cdb file from the Recipients file. /var/qmail/bin/qmail-recipients . Then Create another file under /var/qmail/control/ as recipients with this content.

users/recipients.cdb

Now If you chk your SMTP log file You will see some Entry’s like this.

@4000000048a2703128147d8c Accept::RCPT::Rcpthosts_Rcptto: P:ESMTP S:216.139.212.228:smtp.trustmail.in H:smtp.trustmail.in F:news@steelguru.com T:noc@xyz.com

So Your Spamcontrol is running and It Will Bounce the message if the user is not there in the recipients.cdb file. One thing You have to remeber that after enabling this, when you add a new mail user you’ll have to add that in the /var/qmail/users/recipients file and remake the cdb by /var/qmail/bin/qmail-recipients. Other wise that user will not be able to get mail from Outside.

Now for the second part, you need to add this in your /etc/tcp.smtp LOCALMFCHECK=”" for the allowed IP’s. Like this

203.202.201.11:allow,RELAYCLIENT=”",LOCALMFCHECK=”"

And your /var/qmail/control/rcpthosts file should have all the Domain names that are allowed to use your SMTP Server. Then run qmailctl cdb to remake the cdb file and you are good to go.

I found this two tools very Helpfull, Hope you will also.


Responses

  1. i want to format the log in the follwing format.

    @4000000048a2703128147d8c Accept::RCPT::Rcpthosts_Rcptto: P:ESMTP S:216.139.212.228:smtp.trustmail.in H:smtp.trustmail.in F:news@steelguru.com T:noc@xyz.com

    Please giud me installation of spam controll.

    after running the installation script of spamcontroll.

    compilation of qmail gives error .

    Please guide me

  2. Dear Sunil,

    From where you are installing Qmail? Qmailrocks ?
    you cann’t use the Big Qmail Patch of that script with Spamcontroll and also you cann’t use TAPS with it. Please try without those and be more specific about the Error you are getting.

    Thanks
    Mahin

  3. thanks for your reply.

    i follwed the follwing steps for installing spam controll.

    1. copy and extract the spam controll in the source dir
    /usr/src/qmail/qmail-1.03/

    2. install the spam controll with default conf-spamcontroll by the installation script.

    3. and make the recipirnt file and recipint.cdb file.

    start the service again.

    check the logs of qmail-smtp

    but i did not get these types of logs.

    Please help me.

    thanks.

  4. Dear Sunil,

    After Step 2 did u recompile Qmail with

    “make && make setup check” ?

  5. thanks sir for uour reply

    yes i did it

    but not sucess.

    Please help me sir

    one another issue

    i change the script of qmail-smtpd/run to get these types of logs.

    but i lost more

    now i am not able to get old log also
    my curently logs are as follow

    @4000000049758a92153f4714 tcpserver: status: 1/30
    @4000000049758a92153f6654 tcpserver: pid 6720 from 127.0.0.1
    @4000000049758a9224eac864 tcpserver: ok 6720 tiplmail2.toshiba-india.com:127.0.0.1:900 :127.0.0.1::38518
    @4000000049758a9a0871e744 tcpserver: end 6720 status 0
    @4000000049758a9a0871f2fc tcpserver: status: 0/30

    it is much bad for me.

    i replace orignol file but not get old type of logs.

    i have worked out too much.

    Please sir you are the only hope.

    my contact no 9873936941

    thanks.

  6. Dear Sunil,

    Pls Chk u r Gmail A/C and let me know the feedback.

  7. Dear sir

    i checked my gmail account. but i did not get any mail.

    i need the solution for the folwing types of logs.

    @4000000048a2703128147d8c Accept::RCPT::Rcpthosts_Rcptto: P:ESMTP S:216.139.212.228:smtp.trustmail.in H:smtp.trustmail.in F:news@steelguru.com T:noc@xyz.com

    i can install it again if required.

    Thanks.

  8. Dear sir

    sorry i got mail on other account not on gmail account.

    where to replace qmail-smtpd file.

    thanks

  9. Dear Sunil,

    First Stop Qmail. With This Commands

    /var/qmail/bin/qmailctl stop
    kill -9 `/bin/ps -ef | awk ‘/qmails.*qmail-send/ { print $2 }’`

    Then Take a back up of u r /var/qmail/bin/qmail-smtpd file. Then Replace that file with the one I sent u. And Did chk the /var/qmail/control/recipients file?

    Pls let me know whats the output.

  10. Good going sir, carry on……………


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.