Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Forward mail, but not the SPAM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
eltech
Guru
Guru


Joined: 05 Nov 2002
Posts: 582
Location: New York

PostPosted: Thu Nov 09, 2006 12:14 am    Post subject: [SOLVED] Forward mail, but not the SPAM Reply with quote

Hello ...

So I'm trying to create a setup where mail is sent to my blackberry, but not including mail that is sent to my spam folder.

The setup is qmail and vpopmail. I basically call a script in my .qmail files

Quote:

| /var/qmail/bin/preline /usr/bin/maildrop /var/vpopmail/domains/mailfilter


So I can selectively choose filtering if I want on an account opposed to every account on the box.

The mailfilter file is as follows

Quote:

import EXT
import HOST
import HOME

SPAMBOX=".Spam"
VERBOSE=1
logfile "/var/log/maildrop-filter-log"
SHELL="/bin/sh"
VHOME=`/var/vpopmail/bin/vuserinfo -d $EXT@$HOST`
VDOMHOME=`/var/vpopmail/bin/vdominfo -d $HOST`
VPOP=`cat $VDOMHOME/.qmail-default`

if ((/^X-Spam-Status:.*YES/))
{
`test -d $VHOME/Maildir/.Spam`
if( $RETURNCODE == 1 )
{
`/usr/bin/maildirmake $VHOME/Maildir/.Spam;chown -R vpopmail.vpopmail $VHOME/Maildir/.Spam`
`echo "INBOX.Spam" >> $VHOME/Maildir/courierimapsubscribed`
}
to "$VHOME/Maildir/.Spam/"
}

to "$VHOME/Maildir/"


Standard script to move spam to the spam folder.

My blackberry was configured to check the inbox using the webclient and that works perfectly, but lately my mail is just becoming all unsorted on my workstation so I set some rules to move mail based on subject, addresses, etc to different folders; This all being outlook BTW. I use IMAP on my workstation and the blackberry method also uses IMAP in way that messages deleted on the blackberry can be deleted on the blackberry alone without deleting them from the actual mailbox. So like I said it works fine ..

Problem is with the new rules, It moves the mail to these new folders leaving the inbox empty. SO the blackberry polls the inbox and there isnt any mail to deliver; so i get no mail. So i added an additional line to the .qmail file that reads
Quote:

&myname@nextel.blackberry.net


so it looks like..

Quote:
| /var/qmail/bin/preline /usr/bin/maildrop /var/vpopmail/domains/mailfilter
&myname@nextel.blackberry.net


Simple forward, but its forwarding ALL MAIL. So I get the spam mail also; its tagged and moved to the spam folder as it should on my workstation, but its also getting delivered to my blackberry.

So I hope you see the problem here .. any ideas on a workaround?

Thanks in advance ..


Last edited by eltech on Fri Nov 10, 2006 5:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
dementer
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jan 2004
Posts: 139
Location: New Zealand

PostPosted: Fri Nov 10, 2006 4:34 am    Post subject: Reply with quote

Code:

if ((/^X-Spam-Status:.*YES/))
{
    'test -d $VHOME/Maildir/.Spam`
    <snip nested thing>
    to "$VHOME/Maildir/.Spam/"
}

to "$VHOME/Maildir/"


Couldnt the last bit become part of an an else statement?
Back to top
View user's profile Send private message
eltech
Guru
Guru


Joined: 05 Nov 2002
Posts: 582
Location: New York

PostPosted: Fri Nov 10, 2006 5:13 am    Post subject: Reply with quote

dementer wrote:
Code:

if ((/^X-Spam-Status:.*YES/))
{
    'test -d $VHOME/Maildir/.Spam`
    <snip nested thing>
    to "$VHOME/Maildir/.Spam/"
}

to "$VHOME/Maildir/"


Couldnt the last bit become part of an an else statement?
Not something I would know how to put together ..
Back to top
View user's profile Send private message
dementer
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jan 2004
Posts: 139
Location: New Zealand

PostPosted: Fri Nov 10, 2006 5:18 am    Post subject: Reply with quote

From http://www.courier-mta.org/?maildropfilter.html
Code:

if - conditional execution

    if (expression)
    {
        ...
    }
    else
    {
        ...
    }


The qmail community might be able to help also?
Back to top
View user's profile Send private message
eltech
Guru
Guru


Joined: 05 Nov 2002
Posts: 582
Location: New York

PostPosted: Fri Nov 10, 2006 5:25 am    Post subject: Reply with quote

dementer wrote:
From http://www.courier-mta.org/?maildropfilter.html
Code:

if - conditional execution

    if (expression)
    {
        ...
    }
    else
    {
        ...
    }


You seem to be running qmail? if so the qmail community might have lots of good tips...
This actually wont work because what value or process would the else hold? The problem is actually the process and place of queue the mail is at when forwarding happens. I understand that postfix does this perfectly ..

the only suggestion thus far from qmail is to set the line to look like this

Quote:
to "$VHOME/Maildir/.Spam/ EXITCODE=99"


Whats this do?

Quote:
the EXITCODE=99 makes qmail-local skip any successive delivery
instructions but consider the mail delivered (and thus dequeueing it).


But what this is doing at this point is delivering (spam tagged mail) to the Blackberry and not the mailbox Spam folder .. so its working the opposite way I want it to. :lol:

Thanks for the help!
Back to top
View user's profile Send private message
dementer
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jan 2004
Posts: 139
Location: New Zealand

PostPosted: Fri Nov 10, 2006 5:57 am    Post subject: Reply with quote

eltech wrote:

This actually wont work because what value or process would the else hold? The problem is actually the process and place of queue the mail is at when forwarding happens. I understand that postfix does this perfectly ..

oooh yuck ok sorry bout that
Back to top
View user's profile Send private message
eltech
Guru
Guru


Joined: 05 Nov 2002
Posts: 582
Location: New York

PostPosted: Fri Nov 10, 2006 4:00 pm    Post subject: Reply with quote

So it does work the way I was using, I just had it set incorrectly ..

The way for it to work is below ..

Quote:
if ((/^X-Spam-Status:.*YES/))
{
'test -d $VHOME/Maildir/.Spam`
<snip nested thing>
EXITCODE=99
to "$VHOME/Maildir/.Spam/"

}

to "$VHOME/Maildir/"


The difference to how i had it before was that now its on its own line..

Quote:

YOu're telling maildrop
to deliver it to the .Spam folder, and then set the EXITCODE variable to
99 (which makes maildrop exit with 99, causing qmail-local/vdeliver to
stop processing the .qmail file).


Hence why it shouldnt then reference my forward to my Blackberry in the .qmail file. ..

Pretty slick, but a bit extreme... I might look at postfix as I understand its pretty slick and very flexible..

Thanks for the help ..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum