You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Nicholas Payne-Roberts <ni...@payne-roberts.com> on 2006/07/11 12:58:45 UTC

sa-learn script

Does anybody know a good way to script sa-learn to daily check on junk 
e-mail folders? i'm currently trying the following line in a cron.daily 
script, but its throwing up an error:

find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
--showdots --spam cur {} \;

Error:

Learned tokens from 0 message(s) (0 message(s) examined)
archive-iterator: unable to open cur: No such file or directory

I'm using vpopmail as you can see, and each user has a .Junk E-mail 
folder under their Maildir.

Many thanks,

Nick Payne-Roberts


Re: sa-learn script

Posted by Theo Van Dinter <fe...@apache.org>.
On Tue, Jul 11, 2006 at 12:13:22PM +0100, Chris Lear wrote:
> >Does anybody know a good way to script sa-learn to daily check on junk 
> >e-mail folders? i'm currently trying the following line in a cron.daily 
> >script, but its throwing up an error:
> >
> >find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
> >--showdots --spam cur {} \;
> 
> Your --exec subcommand is the problem. The {} expands to the full path 
> of the found file. It doesn't change directory. A version that might work is

A bigger problem imo is that the file/path you're looking for contains
a space, and {} doesn't quote that for you.  It may be as easy as just
putting single or double quotes around (see the find man page), but may
involve something more complicated ala:

find /home/vpopmail/domains -name ".Junk E-mail" -print0 | \
xargs -0 sa-learn --showdots --spam

or however you want to deal with it.

-- 
Randomly Generated Tagline:
"My daddy shoots people!"
 
 	--Ralph Wiggum
 	  Last Tap Dance in Springfield (Episode BABF15)

Re: sa-learn script

Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
Thats fantastic, thanks very much Chris!


Chris Lear wrote:
> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>> Does anybody know a good way to script sa-learn to daily check on 
>> junk e-mail folders? i'm currently trying the following line in a 
>> cron.daily script, but its throwing up an error:
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
>> --showdots --spam cur {} \;
>
> Your --exec subcommand is the problem. The {} expands to the full path 
> of the found file. It doesn't change directory. A version that might 
> work is
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
> --showdots --spam {}/cur \;
>
> There's not much point using --showdots in cron, I would have thought, 
> but it's probably useful for testing.
>
> To make sure your find command is right, you can do something like this:
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn 
> --showdots --spam {}/cur" \;
>
> which will simply echo a list of commands that would get executed.
>
> Chris

Re: spam script

Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
ah right, excellent, i shall have a play with this and tailor it to my 
setup, thanks Dave.

DAve wrote:
> Nicholas Payne-Roberts wrote:
>> I think my problem is with the usage of the rm command. Even when i 
>> execute it on its own (not within find) it fails to delete the file:
>>
>> rm -f /home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/*
>>
>> Executes with no error and fails to delete the contents of the 
>> directory. Could this simply then be due to the fact that rm will not 
>> delete files in a folder using * unless you are currently inside that 
>> directory?
>>
>
> Not entirely sure this will help but here is a snippet from my spam 
> script which deletes all spam messages over three days old. We run it 
> every night.
>
> SPAM_PATH="$DOMAIN_PATH/.SPAM"
> if [ -d $SPAM_PATH/new ]; then
>     OLDSPAMNEW=`find $SPAM_PATH/new -type f -ctime +3 -exec rm {} \;`
>     OLDSPAMCUR=`find $SPAM_PATH/cur -type f -ctime +3 -exec rm {} \;`
>     echo "  Spam messages removed from $SPAM_PATH" >> $TMP
> else
>     echo "  No spam folder found, moving on." >> $TMP
> fi
>
> $SPAM_PATH is a domain path taken from the vpopmail database plus the 
> name of the spam folder. I do a quick query to see who has spam 
> filtering turned on and who doesn't. Then I just run through the list.
>
> It's worked for about two years now and always finds/deletes the spam 
> messages.
>
> DAve
>

Re: spam script

Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
I think my problem is with the usage of the rm command. Even when i 
execute it on its own (not within find) it fails to delete the file:

rm -f /home/vpopmail/domains/domain.com/nick/Maildir/.Junk E-mail/cur/*

Executes with no error and fails to delete the contents of the 
directory. Could this simply then be due to the fact that rm will not 
delete files in a folder using * unless you are currently inside that 
directory?

Nicholas Payne-Roberts wrote:
> nope, that didn't have any effect either :(
>
> I've tried with -v option but that doesn't show me anything else going 
> on either.
>
> Thanks for your suggestions though Sietse.
>
> Sietse van Zanen wrote:
>> Just a thought, try escapeing the *
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f 
>> {}/cur/\* \;
>>
>> Maybe that helps.
>>  
>> -Sietse
>>  
>>
>> ________________________________
>>
>> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
>> Sent: Wed 12-Jul-06 15:12
>> To: Sietse van Zanen
>> Subject: Re: spam script
>>
>>
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;
>>
>> It just seems to execute without any errors but when you look in any of
>> the cur directories, the files are still there:
>>
>>  find /home/vpopmail/domains -name ".Junk E-mail" -exec ls -l {}/cur \;
>> total 0
>> total 0
>> total 0
>> total 0
>> total 0
>> total 0
>> total 0
>> total 0
>> -rw-r--r--  1 root root 0 Jul 12 16:09 test          <------ a touch'd
>> file i just placed into a cur directory to test the rm command.
>>
>>
>> Sietse van Zanen wrote:
>>  
>>> I thought that was what you wanted.
>>>
>>> Otherwise I would expect the original command with * to be working 
>>> well in removing the files in the ../cur directory. What's going 
>>> wrong with that than?
>>>
>>> -Sietse
>>>
>>> ________________________________
>>>
>>> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
>>> Sent: Wed 12-Jul-06 14:55
>>> To: users@spamassassin.apache.org
>>> Subject: Re: spam script
>>>
>>>
>>>
>>> That deleted all of the cur directory within the .Junk E-mail 
>>> directory.
>>>
>>> Sietse van Zanen wrote:
>>>  
>>>    
>>>> Loose the * and do rm -rf (recursively deletes the directory)
>>>>
>>>> -Sietse
>>>>
>>>> ________________________________
>>>>
>>>> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
>>>> Sent: Wed 12-Jul-06 14:24
>>>> To: users@spamassassin.apache.org
>>>> Subject: spam script
>>>>
>>>>
>>>>
>>>> I am now trying to figure out how to use find in a similar way to tidy
>>>> up those Junk E-mail directories by deleting them after they have been
>>>> used to learn from. This is what i've tried, but the rm command 
>>>> doesn't
>>>> seem to like working with files within the /cur directory...
>>>>
>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f 
>>>> {}/cur/* \;
>>>>
>>>> If i try the above and omit the astrix, it complains about cur being a
>>>> directory:
>>>>
>>>> rm: cannot remove 
>>>> `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk
>>>> E-mail/cur/': Is a directory
>>>>
>>>> Thanks in advance for any suggestions :)
>>>>
>>>> Nick
>>>>
>>>> Chris Lear wrote:
>>>>
>>>>         
>>>>> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>>>>>               
>>>>>> Does anybody know a good way to script sa-learn to daily check on
>>>>>> junk e-mail folders? i'm currently trying the following line in a
>>>>>> cron.daily script, but its throwing up an error:
>>>>>>
>>>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>>>>>> --showdots --spam cur {} \;
>>>>>>                      
>>>>> Your --exec subcommand is the problem. The {} expands to the full 
>>>>> path
>>>>> of the found file. It doesn't change directory. A version that might
>>>>> work is
>>>>>
>>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>>>>> --showdots --spam {}/cur \;
>>>>>
>>>>> There's not much point using --showdots in cron, I would have 
>>>>> thought,
>>>>> but it's probably useful for testing.
>>>>>
>>>>> To make sure your find command is right, you can do something like 
>>>>> this:
>>>>>
>>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn
>>>>> --showdots --spam {}/cur" \;
>>>>>
>>>>> which will simply echo a list of commands that would get executed.
>>>>>
>>>>> Chris
>>>>>                
>>>>          
>>>  
>>>     
>>
>>
>>   

Re: spam script

Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
nope, that didn't have any effect either :(

I've tried with -v option but that doesn't show me anything else going 
on either.

Thanks for your suggestions though Sietse.

Sietse van Zanen wrote:
> Just a thought, try escapeing the *
> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/\* \;
>
> Maybe that helps.
>  
> -Sietse
>  
>
> ________________________________
>
> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
> Sent: Wed 12-Jul-06 15:12
> To: Sietse van Zanen
> Subject: Re: spam script
>
>
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;
>
> It just seems to execute without any errors but when you look in any of
> the cur directories, the files are still there:
>
>  find /home/vpopmail/domains -name ".Junk E-mail" -exec ls -l {}/cur \;
> total 0
> total 0
> total 0
> total 0
> total 0
> total 0
> total 0
> total 0
> -rw-r--r--  1 root root 0 Jul 12 16:09 test          <------ a touch'd
> file i just placed into a cur directory to test the rm command.
>
>
> Sietse van Zanen wrote:
>   
>> I thought that was what you wanted.
>>
>> Otherwise I would expect the original command with * to be working well in removing the files in the ../cur directory. What's going wrong with that than?
>>
>> -Sietse
>>
>> ________________________________
>>
>> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
>> Sent: Wed 12-Jul-06 14:55
>> To: users@spamassassin.apache.org
>> Subject: Re: spam script
>>
>>
>>
>> That deleted all of the cur directory within the .Junk E-mail directory.
>>
>> Sietse van Zanen wrote:
>>  
>>     
>>> Loose the * and do rm -rf (recursively deletes the directory)
>>>
>>> -Sietse
>>>
>>> ________________________________
>>>
>>> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
>>> Sent: Wed 12-Jul-06 14:24
>>> To: users@spamassassin.apache.org
>>> Subject: spam script
>>>
>>>
>>>
>>> I am now trying to figure out how to use find in a similar way to tidy
>>> up those Junk E-mail directories by deleting them after they have been
>>> used to learn from. This is what i've tried, but the rm command doesn't
>>> seem to like working with files within the /cur directory...
>>>
>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;
>>>
>>> If i try the above and omit the astrix, it complains about cur being a
>>> directory:
>>>
>>> rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk
>>> E-mail/cur/': Is a directory
>>>
>>> Thanks in advance for any suggestions :)
>>>
>>> Nick
>>>
>>> Chris Lear wrote:
>>>
>>>    
>>>       
>>>> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>>>>   
>>>>      
>>>>         
>>>>> Does anybody know a good way to script sa-learn to daily check on
>>>>> junk e-mail folders? i'm currently trying the following line in a
>>>>> cron.daily script, but its throwing up an error:
>>>>>
>>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>>>>> --showdots --spam cur {} \;
>>>>>     
>>>>>        
>>>>>           
>>>> Your --exec subcommand is the problem. The {} expands to the full path
>>>> of the found file. It doesn't change directory. A version that might
>>>> work is
>>>>
>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>>>> --showdots --spam {}/cur \;
>>>>
>>>> There's not much point using --showdots in cron, I would have thought,
>>>> but it's probably useful for testing.
>>>>
>>>> To make sure your find command is right, you can do something like this:
>>>>
>>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn
>>>> --showdots --spam {}/cur" \;
>>>>
>>>> which will simply echo a list of commands that would get executed.
>>>>
>>>> Chris
>>>>   
>>>>      
>>>>         
>>>    
>>>       
>>  
>>     
>
>
>   

RE: spam script

Posted by Sietse van Zanen <si...@wizdom.nu>.
I thought that was what you wanted.
 
Otherwise I would expect the original command with * to be working well in removing the files in the ../cur directory. What's going wrong with that than?
 
-Sietse

________________________________

From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
Sent: Wed 12-Jul-06 14:55
To: users@spamassassin.apache.org
Subject: Re: spam script



That deleted all of the cur directory within the .Junk E-mail directory.

Sietse van Zanen wrote:
> Loose the * and do rm -rf (recursively deletes the directory)
> 
> -Sietse
>
> ________________________________
>
> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
> Sent: Wed 12-Jul-06 14:24
> To: users@spamassassin.apache.org
> Subject: spam script
>
>
>
> I am now trying to figure out how to use find in a similar way to tidy
> up those Junk E-mail directories by deleting them after they have been
> used to learn from. This is what i've tried, but the rm command doesn't
> seem to like working with files within the /cur directory...
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;
>
> If i try the above and omit the astrix, it complains about cur being a
> directory:
>
> rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk
> E-mail/cur/': Is a directory
>
> Thanks in advance for any suggestions :)
>
> Nick
>
> Chris Lear wrote:
>  
>> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>>    
>>> Does anybody know a good way to script sa-learn to daily check on
>>> junk e-mail folders? i'm currently trying the following line in a
>>> cron.daily script, but its throwing up an error:
>>>
>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>>> --showdots --spam cur {} \;
>>>      
>> Your --exec subcommand is the problem. The {} expands to the full path
>> of the found file. It doesn't change directory. A version that might
>> work is
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>> --showdots --spam {}/cur \;
>>
>> There's not much point using --showdots in cron, I would have thought,
>> but it's probably useful for testing.
>>
>> To make sure your find command is right, you can do something like this:
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn
>> --showdots --spam {}/cur" \;
>>
>> which will simply echo a list of commands that would get executed.
>>
>> Chris
>>    
>
>
>  



Re: spam script

Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
That deleted all of the cur directory within the .Junk E-mail directory.

Sietse van Zanen wrote:
> Loose the * and do rm -rf (recursively deletes the directory)
>  
> -Sietse
>
> ________________________________
>
> From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
> Sent: Wed 12-Jul-06 14:24
> To: users@spamassassin.apache.org
> Subject: spam script
>
>
>
> I am now trying to figure out how to use find in a similar way to tidy
> up those Junk E-mail directories by deleting them after they have been
> used to learn from. This is what i've tried, but the rm command doesn't
> seem to like working with files within the /cur directory...
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;
>
> If i try the above and omit the astrix, it complains about cur being a
> directory:
>
> rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk
> E-mail/cur/': Is a directory
>
> Thanks in advance for any suggestions :)
>
> Nick
>
> Chris Lear wrote:
>   
>> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>>     
>>> Does anybody know a good way to script sa-learn to daily check on
>>> junk e-mail folders? i'm currently trying the following line in a
>>> cron.daily script, but its throwing up an error:
>>>
>>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>>> --showdots --spam cur {} \;
>>>       
>> Your --exec subcommand is the problem. The {} expands to the full path
>> of the found file. It doesn't change directory. A version that might
>> work is
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>> --showdots --spam {}/cur \;
>>
>> There's not much point using --showdots in cron, I would have thought,
>> but it's probably useful for testing.
>>
>> To make sure your find command is right, you can do something like this:
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn
>> --showdots --spam {}/cur" \;
>>
>> which will simply echo a list of commands that would get executed.
>>
>> Chris
>>     
>
>
>   

RE: spam script

Posted by Sietse van Zanen <si...@wizdom.nu>.
Loose the * and do rm -rf (recursively deletes the directory)
 
-Sietse

________________________________

From: Nicholas Payne-Roberts [mailto:nick@payne-roberts.com]
Sent: Wed 12-Jul-06 14:24
To: users@spamassassin.apache.org
Subject: spam script



I am now trying to figure out how to use find in a similar way to tidy
up those Junk E-mail directories by deleting them after they have been
used to learn from. This is what i've tried, but the rm command doesn't
seem to like working with files within the /cur directory...

find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;

If i try the above and omit the astrix, it complains about cur being a
directory:

rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk
E-mail/cur/': Is a directory

Thanks in advance for any suggestions :)

Nick

Chris Lear wrote:
> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>> Does anybody know a good way to script sa-learn to daily check on
>> junk e-mail folders? i'm currently trying the following line in a
>> cron.daily script, but its throwing up an error:
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
>> --showdots --spam cur {} \;
>
> Your --exec subcommand is the problem. The {} expands to the full path
> of the found file. It doesn't change directory. A version that might
> work is
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn
> --showdots --spam {}/cur \;
>
> There's not much point using --showdots in cron, I would have thought,
> but it's probably useful for testing.
>
> To make sure your find command is right, you can do something like this:
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn
> --showdots --spam {}/cur" \;
>
> which will simply echo a list of commands that would get executed.
>
> Chris



Re: spam script

Posted by "John D. Hardin" <jh...@impsec.org>.
On Wed, 12 Jul 2006, Nicholas Payne-Roberts wrote:

> I am now trying to figure out how to use find in a similar way to
> tidy up those Junk E-mail directories by deleting them after they
> have been used to learn from.

Keep 'em. It simplifies retraining from scratch should you need to do
so and untraining if somebody misclassifies a message.

If you don't want sa-learn to have to wade through them, then move
them to a different directory.

If you want to use less disk space, then compress them.

--
 John Hardin KA7OHZ    ICQ#15735746    http://www.impsec.org/~jhardin/
 jhardin@impsec.org    FALaholic #11174    pgpk -a jhardin@impsec.org
 key: 0xB8732E79 - 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
  The first time I saw a bagpipe, I thought the player was torturing
  an octopus. I was amazed they could scream so loudly.
                                        -- cat_herder_5263 on Y! SCOX
-----------------------------------------------------------------------
 12 days until The 37th anniversary of Apollo 11 landing on the Moon


spam script

Posted by Nicholas Payne-Roberts <ni...@payne-roberts.com>.
I am now trying to figure out how to use find in a similar way to tidy 
up those Junk E-mail directories by deleting them after they have been 
used to learn from. This is what i've tried, but the rm command doesn't 
seem to like working with files within the /cur directory...

find /home/vpopmail/domains -name ".Junk E-mail" -exec rm -f {}/cur/* \;

If i try the above and omit the astrix, it complains about cur being a 
directory:

rm: cannot remove `/home/vpopmail/domains/domain.com/nick/Maildir/.Junk 
E-mail/cur/': Is a directory

Thanks in advance for any suggestions :)

Nick

Chris Lear wrote:
> * Nicholas Payne-Roberts wrote (11/07/06 11:58):
>> Does anybody know a good way to script sa-learn to daily check on 
>> junk e-mail folders? i'm currently trying the following line in a 
>> cron.daily script, but its throwing up an error:
>>
>> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
>> --showdots --spam cur {} \;
>
> Your --exec subcommand is the problem. The {} expands to the full path 
> of the found file. It doesn't change directory. A version that might 
> work is
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
> --showdots --spam {}/cur \;
>
> There's not much point using --showdots in cron, I would have thought, 
> but it's probably useful for testing.
>
> To make sure your find command is right, you can do something like this:
>
> find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn 
> --showdots --spam {}/cur" \;
>
> which will simply echo a list of commands that would get executed.
>
> Chris

Re: sa-learn script

Posted by Chris Lear <ch...@laculine.com>.
* Nicholas Payne-Roberts wrote (11/07/06 11:58):
> Does anybody know a good way to script sa-learn to daily check on junk 
> e-mail folders? i'm currently trying the following line in a cron.daily 
> script, but its throwing up an error:
> 
> find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
> --showdots --spam cur {} \;

Your --exec subcommand is the problem. The {} expands to the full path 
of the found file. It doesn't change directory. A version that might work is

find /home/vpopmail/domains -name ".Junk E-mail" -exec  sa-learn 
--showdots --spam {}/cur \;

There's not much point using --showdots in cron, I would have thought, 
but it's probably useful for testing.

To make sure your find command is right, you can do something like this:

find /home/vpopmail/domains -name ".Junk E-mail" -exec echo "sa-learn 
--showdots --spam {}/cur" \;

which will simply echo a list of commands that would get executed.

Chris

Re: sa-learn script

Posted by Bart Schaefer <ba...@gmail.com>.
On 7/11/06, Nicholas Payne-Roberts <ni...@payne-roberts.com> wrote:
> Does anybody know a good way to script sa-learn to daily check on junk
> e-mail folders?

I use logrotate because it handles automatically removing or renaming
the files after learning, but I don't use maildir-format folders so I
can't provide a tested configuration.

Something like this:

notifempty
missingok
"/home/vpopmail/domains/*/*/.Junk E-mail/cur/*" {
  rotate 0
  daily
  nomail
  prerotate
     spamc -t 20 -l -L spam < "$1"
  endscript
}

Be careful of that "rotate 0" which means to delete the file.  If
there's any chance that a false-positive might need to be recovered
later, you probably want to increase that and add an "olddir"
directive to tell logrotate where to archive the spam.

If you have logrotate running regularly as a system process, that
config would go in (for example, may vary by OS distribution)
/etc/logrotate.d/sa-learn.  If not or if you have to run logrotate  as
a user other than root, put that in a file somewhere in the correct
user's home directory (I like to use a subdirectory named ".logrotate"
and name the file "conf") and install a crontab entry for that user,
similar to

1 3 * * * logrotate -f --state $HOME/.logrotate/state $HOME/.logrotate/conf