LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-08-2004, 01:55 PM   #1
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Rep: Reputation: 0
Block emails which has no 'from email address' using qmail


Hi,
I am a new newbie with respect to qmail.
I am stuck, I need a way to block emails which have no 'from address' because these junk mails freezes email clients like Outlook, Eudora. I used spamassisins well it never really worked.

Any help would be really appreciated

Thanks

Harry
 
Old 11-09-2004, 03:10 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
I don't know qmail at all. But if it can interface somehow with procmail, then procmail can do the job.

Yves.
 
Old 11-09-2004, 03:27 AM   #3
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Another very good prog that can manage this for you is maildrop.
Check it out at http://www.courier-mta.org/maildrop/
 
Old 11-09-2004, 04:55 PM   #4
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
I did install and configure both maildrop and spamassassin but no luck.

I also installed mailfilter too there I created a file called mailfilterrc

The file has this configuration


# This one filters mail from a certain person:
DENY = ^From:.*spammer@any_spam_organisation.com

# This one filters mail from everyone at a certain
# organisation:
DENY = ^From:.*@any_provider_that_spams.org


Do you all know any ways to alter this file in such a way that the the email with no'from' address could be blocked?

Thanks

Harry

Last edited by linuxharry; 11-09-2004 at 04:56 PM.
 
Old 11-10-2004, 02:14 AM   #5
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Please post your entire .mailfilterrc. Also tell me the FULL path to the file (including the mailfilterrc part)
I hope :
<snip>
# This one filters mail from a certain person:
DENY = ^From:.*spammer@any_spam_organisation.com

# This one filters mail from everyone at a certain
# organisation:
DENY = ^From:.*@any_provider_that_spams.org
<pins>
are just examples & not what you actualy have in your .mailfilterrc file!
 
Old 11-10-2004, 04:31 PM   #6
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Hi Guys,

Thanks a lot for showing interest. As per your request I am sending you the .mailfilterrc file. The list is longer I have just edited to fit the content in this forum.
I have stored this in /var/qmail directory. Am i wrong here?

Secondly I am sure I need to edit this line in order to filter any mail without any subject.

DENY = ^From:.*@blockthisemail.com

I just dont have the right idea to do this. Alot of clients complain if they receive any email with no subject their email client software (like, outlook, eudora) gets frozen. I would really appreciate if any one can give me a right lead to solve this issue


The complete file is


#
# -----------------------------------------------------------
# Logile path (be sure you have write permission in this
# directory; you MUST specify a logfile)
LOGFILE = $HOME/.mailfilter.log# -----------------------------------------------------------
# Level of verbosity
#
# 0 Silent, show nothing at all
#
# 1 Only show errors
#
# 2 Only show "Deleted..." messages and errors
#
# 3 Default; Show "Deleted..." messages, errors and
# "Examining..." messages
#
# 4 Like (3), except this also shows the current
# account's username
#
# 5 Like (4), except this also shows which filter
# matched which string of an e-mail header
#
# 6 Debugging mode; prints out almost everything
VERBOSE = 3# -----------------------------------------------------------
# POP3 server list (do not change the order of the fields!)
# Note: Port 110 is usually the port POP3 servers use.
# Currently only POP3 is supported.
SERVER = *****
USER = *****
PASS = *****
PROTOCOL = pop3
PORT = 110
# -----------------------------------------------------------
# Do you want case sensitive e-mail filters? { yes | no }
REG_CASE = no# -----------------------------------------------------------
# Sets the type of Regular Expression used { extended | basic }
#
# (The default is 'basic', don't change unless you know what
# you are doing. Extended REs are more complex to set up.)
REG_TYPE = basic# -----------------------------------------------------------
# Maximum e-mail size in bytes that should not be exceeded.
MAXSIZE_DENY = 1000000# ----------------------------------------------------------
# Filter rules for detecting spam (each rule must be placed
# in a seperate line)
# These filters detect certain unpleasant e-mail subjects:
DENY = ^Subject:.*Get penis enlargement
DENY = ^Subject:.*WIN MONEY
DENy = ^Subject:. Get free car
# This one filters mail from a certain person:
DENY = ^From:.*spammer@any_spam_organisation.com
# This one filters mail from everyone at a certain
# organisation:



# We don't want any of those 'LEGAL' messages either
# while stuff with 'legal' in the subject still interests us:
DENY_CASE = ^Subject:.*LEGAL# -----------------------------------------------------------
# Normalises the subject strings before parsing, e.g.
# ',L.E-G,A.L; ,C.A-B`L`E, +.B-O`X` ;D`E`S,C;R,A.MB;L,E.R-]'
# becomes 'LEGAL CABLE BOX DESCRAMBLER' which can be filtered.
NORMAL = yes# -----------------------------------------------------------
# The maximum e-mail size in bytes that messages from friends
# should not exceed. Set this to 0 if all your friends (ALLOW)
# can send messages as long as they want.
MAXSIZE_ALLOW = 0# ----------------------------------------------------------
# Set list of friends that always pass, if they do not

# Of course we allow e-mail from anyone who has something to
# say about mailfilter:
ALLOW = ^Subject:.*mailfilter
# Block the emails that sucks:

DENY = ^From:.*@dailytty.com
DENY = ^From:.*@yourslucky.com
DENY = ^From:.*@manlikes.com
DENY = ^From:.*@dreamcars.com

Last edited by linuxharry; 11-10-2004 at 04:33 PM.
 
Old 11-13-2004, 07:31 AM   #7
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Gezz linuxharry, you are a newbie!
First off, it looks as though you have simply copied an example .mailfilterrc file without editing it to suit your needs.
I am not a mailfilter expert by any means, I've never even used it before, but after reading a little bit from http://mailfilter.sourceforge.net/documentation.html it looks like a very capable mail filtering program & should easily do what you ask of it.
The line: "DENY = ^From:.*@blockthisemail.com" means - DENY any mail (any user name (*)) that comes from the domain, "blockthisemail.com". It reads quite literately. YOU are supposed to change the "blockthisemail.com" part to the name of any domain that you want to block ALL mail from, which is not what you are looking for.
But, for the sake of learning it, the ^ symbol means "only match this if it is at the start of a line" in regular expressions talk. If you are unfamiliar with regular expressions then I would highly advise you to learn them, they are at the heart of many config files through-out Linux. At http://mailfilter.sourceforge.net/documentation.html there is a link to "A Brief Introduction to Regular Expressions". This would be a very good place to start. It is not essential that you learn them 100%, but at least familiarize yourself with them, you will find them invaluable.
Anyway, getting back to your original concern, blocking all mail with no user in the FROM: line.
Have you read mailfilter's man files? Particularly mailfilerrc & mailfilterex? These will explain how the syntax works. After a bit of education mailfilter style you should then google around for what other people have put in their .mailfilterrc file. At google, try: mailfilter ".mailfilterrc" "FROM:" This gets many good hits. Another great place to get info on mailfilter is the mailfilter forum at sourceforge,
http://sourceforge.net/mailarchive/f...?forum_id=1875 should get you there.
But it's no good knowing how to write a .mailfilterrc file if mailfilter is not being asked by qmail to filter your mail. Qmail needs to be told to use mailfilter or it just won't work. But I know nothing of your qmail setup. If you are using vpopmail then your .mailfilterrc file is in the wrong place. Can you tell me how you learned how to install qmail? Did you follow a step-by-step tutorial? If so, which one? There are many different ways of configuring how qmail, & the other programs that interact with qmail should work. If I don't know how you set yours up, I can't help you to make sure you have set it up correctly.

Get back to me with this info & READ, READ, READ.
 
Old 11-15-2004, 01:07 PM   #8
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Hello fuzzyash,
Thanks a lot for going through my message. Well I did actually go through Qmail . I just sent you a dummy .mailfilterrrc. Let me explain more elaborately
I have loaded vpopmail in /home directory.

The mailfilter spam is actually stored in /downloads/mail/spam_system/domain/mailfilter

Mailfilter is a perl script file which has certain tasks to filter out the emails.

To enable mailfilter for a dmain say test.com I use
cp -p /downloads/mail/spam_system/domain/mailfilter /home/vpopmail/domains/test.com
i chmod 600 that .mailfilter file which is created in that domain.

The fact this stuff works for mail spam in general.

Now what I gathered is .mailfilterrc file actually filters individual domains where it can block emails by specifying in that config file.

This is where I am stuck. Now I got the pop server right. I am stuck here right now they say user does it mean I should give ron@test.com or ron would just do. If its just 'ron' what should I do if there are more users with different domain names?

SERVER=mail.mailadcom.net
USER=ron
PASS=ron
PROTOCOL=pop3
PORT=110


I did this I created a new user by name ron and password ron and added this file in the home directory /home/ron. Am I right so far? This so far hasent worked?

#
SERVER=mail.mailadcom.net
USER=ron
PASS=ron
PROTOCOL=pop3
PORT=110

#
# General configuration
#
REG_CASE=no
REG_TYPE=extended
DEL_DUPLICATES=no
SHOW_HEADERS=no
LOGFILE=/Users/YOUR_USERNAME_HERE/Library/Logs/mailfilter.log
VERBOSE=5

#
# DENY rules
#
# Base ruleset by pb@e-scribe.com 2002-04-16
#
#
# DENY rules
#
DENY<>^From:.*@.*
DENY<>^Subject:
DENY=^1:
#DENY=^Content-Type:\ text/html;
DENY=^From:.*\%\ off
DENY=^From:.*\.\.\.
#DENY=^From:.*pennyhaven
#DENY=^From:.*poledu\.com
DENY_CASE=^DATE:
DENY_CASE=^FROM:
DENY_CASE=^MiME-Version:
DENY_CASE=^SUBJECT:
#DENY_CASE=^content-type
#DENY_CASE=^x-esmtp:

Last edited by linuxharry; 11-15-2004 at 02:11 PM.
 
Old 11-17-2004, 02:42 AM   #9
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Ah... Thats more like it. What are you trying to do with mailfilter? Are you trying to download all the mail common to your domain (i.e. test.com) from a remote server & then distribute it to your users on your privet network, or are you trying to setup a mail relay server?
Also, I asked in my previous message how you learned how to install qmail. I am guessing that you used a tutorial or you would be completely bald by now. It would help me a great deal if I know how you are setup.
 
Old 11-17-2004, 04:19 AM   #10
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
I have figured out how to achieve this using maildrop but I have never seen a message with no user name in the FROM: line. Could you post the the headers from the source of one of these messages for me to have a look at. Be sure to tell me how you learned how to configure qmail or I won't know where you should put the config files.
 
Old 11-17-2004, 03:07 PM   #11
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Hello fuzzyash,

Well I actually took over this portfolio from another person. He did the installations.
Well its installed in a remote server. Well the domains are stored in the /home/vpopmain/domains
domains contain xxx.com, xyz.com etc etc

Here lies the problem there are no headers displayed in the email client thats where the problem lies, if its eudora or express it hangs outlook2000 handles this.

Thats where I am stuck as to how can we block an email with no headers?

I managed to figure out the ip address
200.168.159.222
can we block using ipaddress also?
 
Old 11-17-2004, 03:09 PM   #12
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
.mailfilter file is stored in the /home/vpopmail/domains/test.com directory

Have to figure out where to put mailfilterrrc for it to exactly work
 
Old 11-19-2004, 08:33 AM   #13
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
When you say ".mailfilter file is stored in the /home/vpopmail/domains/test.com directory" I am assuming you mean your .mailfilterrc file. I am fairly sure that is the correct place for this file (that is where maildrops config file is stored which is called mailfilter) The .qmail-default file in /home/vpopmail/domains/test.com needs to be configured correctly for qmail to use mailfilter. Could you post /home/vpopmail/domains/test.com/.qmail-default for me to have a look at.
 
Old 11-22-2004, 11:04 AM   #14
linuxharry
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Hi fuzzyash,

Actually mailfilterrc is used when we use procmail. This email server does not use procmail . We use .mailfilter which is a perlscript that runs with mailfilter addin agent for spamassassin.

Let me give you the .mailfilter file

SHELL="/bin/sh"
import EXT
import HOST
VPOP="| /usr/local/vpopmail/bin/vdelivermail '' bounce-no-mailbox"
VHOME=`/usr/local/vpopmail/bin/vuserinfo -d $EXT@$HOST`

##
# Create a .qmail-default file with the following:
# "| /usr/local/bin/maildrop mailfilter"
#
# After your satisifed that this is working properly, comment out all
# the lines that start with "log"
##

logfile "/var/log/mail/maildrop.log"
log "==== BEGIN maildrop processing for $EXT@$HOST ==="

if ( $VHOME eq "" )
{
LOG " ERROR: VHOME isn't set, falling back to vdelivermail"
LOG "=== EXIT === "
to "$VPOP"
}

##
# Comment out this section if you run SpamAssassin via qmailscanner
# Spamassassin is slow enough, no point in doubling your expense
#
# Note that if you want to pass a message larger than 250k to spamd
# and have it processed, you'll need to also set spamc -s. See the
# spamc man page for more details.
##

if ( $SIZE < 256000 ) # Filter if message is less than 250k
{
log " running message through spamc"
exception {
xfilter '/usr/local/bin/spamc -u "$EXT@$HOST"'
}
}


##
# Include any rules set up for the user - this gives the
# administrator a way to override the domain's mailfilter file
#
# this is also the "suggested" way to set individual values
# for maildrop such as quota.
##

`test -r $VHOME/.mailfilter`
if( $RETURNCODE == 0 )
{
log " including $VHOME/.mailfilter"
exception {
include $VHOME/.mailfilter
}
}

##
# create the maildirsize file if it doesn't already exist
# (could also be done via "deliverquota user@dom.com 10MS,1000C)
##
`test -e $VHOME/Maildir/maildirsize`
if( $RETURNCODE == 1)
{
log " creating $VHOME/Maildir/maildirsize for quotas"
`/usr/local/vpopmail/bin/vuserinfo -Q $EXT@$HOST`

`test -s "$VHOME/Maildir/maildirsize"`
if ( $RETURNCODE == 0 )
{
`/usr/sbin/chown vpopmail:vchkpw $VHOME/Maildir/maildirsize`
`/bin/chmod 640 $VHOME/Maildir/maildirsize`
}
}

##
# Set MAILDIRQUOTA. If this isn't set, maildrop and deliverquota
# will not enforce quotas for message delivery.
#
# I find this much easier than creating yet another config file
# to store this in. This way, any time the quota is changed in
# vpopmail, it'll get noticed by maildrop immediately.
##

MAILDIRQUOTA=`/usr/bin/head -n1 $VHOME/Maildir/maildirsize`

##
# The message should be tagged, so let's bag it.
##
if ( /^X-Spam-Status: *Yes/)
{
`test -d $VHOME/Maildir/.Spam` # make sure .Spam folder exists
if( $RETURNCODE == 1 )
{
log " creating $VHOME/Maildir/.Spam "
`maildirmake -f Spam $VHOME/Maildir`
`/usr/local/sbin/subscribeIMAP.sh Spam $VHOME`
}

log " SPAM: attempting quota delivery to $VHOME/Maildir/.Spam"
exception {
xfilter "/usr/local/bin/deliverquota $VHOME/Maildir/.Spam"
}

if( $RETURNCODE == 77)
{
log " QUOTA FAILURE: bouncesaying '$EXT@$HOST is over quota'"
to "|/var/qmail/bin/bouncesaying '$EXT@$HOST is over quota'"
}

log "=== END === success"
exit
}

log " message is clean"

##
# Include any other rules that the user might have from
# sqwebmail or other compatible program
##

`test -r $VHOME/Maildir/.mailfilter`
if( $RETURNCODE == 0 )
{
log " including $VHOME/Maildir/.mailfilter"
exception {
include $VHOME/Maildir/.mailfilter
}
}

exception {
log " quota enabled delivery to $VHOME/Maildir"
xfilter "/usr/local/bin/deliverquota $VHOME/Maildir"
}

##
# check to make sure the message was delivered
# returncode 77 means that out maildir was overquota - bounce mail
##
if( $RETURNCODE == 77)
{
log " BOUNCED: bouncesaying '$EXT@$HOST is over quota'"
to "|/var/qmail/bin/bouncesaying '$EXT@$HOST is over quota'"
}

log "=== END === success"



If you look at this part this is where we could actually edit the content to filter out emails with no headers

##
# The message should be tagged, so let's bag it.
##
if ( /^X-Spam-Status: *Yes/)
{
`test -d $VHOME/Maildir/.Spam` # make sure .Spam folder exists
if( $RETURNCODE == 1 )
{
log " creating $VHOME/Maildir/.Spam "
`maildirmake -f Spam $VHOME/Maildir`
`/usr/local/sbin/subscribeIMAP.sh Spam $VHOME`
}

log " SPAM: attempting quota delivery to $VHOME/Maildir/.Spam"
exception {
xfilter "/usr/local/bin/deliverquota $VHOME/Maildir/.Spam"
}

if( $RETURNCODE == 77)
{
log " QUOTA FAILURE: bouncesaying '$EXT@$HOST is over quota'"
to "|/var/qmail/bin/bouncesaying '$EXT@$HOST is over quota'"
}

log "=== END === success"
exit
}




You also wanted the .qmail-default right?

it is
| /usr/local/bin/maildrop mailfilter

Thanks

Harish
 
Old 11-27-2004, 07:50 PM   #15
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
G'day linuxharry,
Sorry about taking so long to get back yo you, I've been rather busy.

OK. .qmail-default is the file that qmail looks at to find the command to run on each new message it tries to deliver to a particular domain, in this case /home/vpopmail/domains/test.com. The command in there is "| /usr/local/bin/maildrop mailfilter" which says, obviously, pipe each new message thru /usr/local/bin/maildrop & use the file "mailfilter" as the config file for maildrop. So this means you are using maildrop, not mailfilter! .mailfilter is NOT a Perl script, (although it look alot like Perl) it is the config file for maildrop! (see http://www.courier-mta.org/maildrop/maildropfilter.html for details) Your .qmail-default file says it is looking for a file called mailfilter, not .mailfilter, (note the "." is NOT prefixing the actual file name) Are you sure that this file begins with a "."? Be sure to confirm the correct name. If it has a "." then change the word in your .qmail-default file from mailfilter to .mailfilter. If it is named .mailfilter then we've got problems, qmail wouldn't work at all if it can't find the file it is asked for in .qmail-default, but your qmail obviously IS working so mailfilter must exist. The file mailfilter should be located in the same dir as the .qmail-default.

Alright, seeings that you are actually running maildrop & not mailfilter that makes things a breeze, so lets get down to the nitty gritty!
To block any mail that has no address in the FROM: line, just add these lines to the very end of the mailfilter file in whatever domain that you want to block these type messages from:

#~~~~~<SNIP>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if (/^FROM:$/)
{
to "/home/vpopmail/domains/test.com/postmaster/Maildir/" # This will send these messages to postmaster
# to "/dev/null" # This will blast them in oblivion! (uncomment this & comment out the above if thats what you want)
}
else
{
to "$VPOP"
}

#~~~~~<PINS>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Because you can't send me the source of an email with no FROM: address then I have to assume this is correct. If you can get your hands on one & post it, I would be able to test this & ensure that it works correctly. If this does't work you'll have to play around with the (/^FROM:$/) part. As is, this says: If a message has a line that starts (^) with FROM: & ends ($) with no other text (except white space) then preform this action on it (commands between { and }). After making the changes to your mailfilter file, & without editing what I've written above, paste this into a file somewhere:

#~~~~~<SNIP>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From:
To: <ANYONE_EXCEPT_POSTMASTER@YOUR.DOMAIN.COM>
Subject: test

test

#~~~~~<PINS>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then run: cat </NAME/OF/FILE/YOU/SAVED/AS> | /var/qmail/bin/qmail-inject
Then have a look at your postmaster account, this message should have been delivered there!
Anyway, thats it! Your problem seems to be that you thourght you were running mailfilter when you are realy running maildrop. Read the man files maildropfilter & maildropex or visit http://www.courier-mta.org/maildrop/ for more on this subject.

Post your results here to let me know how you went.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Qmail sending emails slow...... help gabriellai Linux - Networking 2 06-06-2005 03:28 AM
Qmail Email. Some emails are duplicated. kemplej Linux - Networking 3 02-01-2005 08:21 AM
How to Forwarding all old emails to a new email address tvn Linux - Software 1 12-04-2004 07:48 PM
qmail not sending emails lsimon4180 Linux - Software 1 10-18-2004 11:35 PM
block/bounce emails using qmail enzo250gto Linux - Software 0 04-07-2004 02:31 AM


All times are GMT -5. The time now is 02:17 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration