Web Hosting Forum | Lunarpages

Author Topic: How To: Remove spam automatically  (Read 12396 times)

Offline Trey

  • Jedi
  • *****
  • Posts: 933
    • http://www.singfreemusic.com
How To: Remove spam automatically
« on: April 24, 2004, 09:02:18 AM »
This how-to is useful if you have spamassassin and spambox enabled in cPanel.

We all know that this causes spam to be moved to a folder called "spam" that can be checked using an IMAP connection, or Horde's webmail interface, but some of us are too busy to delete these mails, and they DO take up space as well.

Some of us even have too many messages hitting this folder each day, so we don't have time to do it, right?  Right.

Well, I've written yet another extremely short how-to for those of us who can't take the time to delete eleventy-billion spams from the spam folder each hour.

Here goes....

===============================================


Requirements:

Your spamassassin and spambox must be enabled in cPanel.

Please note that the setup I'm about to explain will NOT save spam on your account for long, so keep in mind that if spam assassin marks a legitimate email as spam, then unless you happen to catch it before the actions I'm about to show occur, then that email will be lost.  So, I'd recommend reading Danielle's How-to on training SpamAssassin before you partake of this fun and fantabulous journey.

I take no responsibility for legitimate emails that were marked by SpamAssassin being lost, if that happens.  That being said, by reading this you agree to the terms and conditions as outlined by me at any given time.  Shipping and handling is not included.

===============================================


How-to:

1.  Ensure that SpamAssassin and spambox are enabled on your account.  This can be checked in the Mail section of cPanel, under the "SpamAssassin" listing.

2.  Ensure, and I mean ENSURE!!!, that SpamAssassin hasn't been catching legitimate emails sent to you.  (As I stated, I recommend using Danielle's How-to on training SpamAssassin before you attempt this how-to.)

3.  Log into cPanel.

4.  Scroll down and click on "Cron Jobs".

5.  You'll be presented with 2 buttons.  For this How-to, we're using the "Standard" set.  If you're really brave, and/or know Unix well enough, go for the Advanced.

6.  You'll see a field stating "Please enter an email address where the cron output will be sent:" and a text box next to that.  Enter your email address, or leave the account username there to have it email the default "catch all" account.

7.  You'll see another text-field with "Command to run:" to the left.

In this box, enter the following command:

rm -f /home/your_account_username/mail/your_domain/your_email/spam

Legend:

"your_account_username"  =  your cpanel username
"your_domain" = your domain, with no "http://" or "www."
"your_email" = your email address BEFORE the @.  For example, my email address is "bob@bobbywooo.com".  The entry would be "bob" without quotes.

So, if my account was bob2, this would be the command:

rm -f /home/bob2/mail/bobbywooo.com/bob/spam

If you're on one of the EMC servers, your path will need to be "/nfs/home/bob2/mail/bobbywooo.com/bob/spam" instead of just "/home/username".

8.  Next, you'll see the "minutes, hours, etc." fields.

Skip "Minutes".  Leave it at 0.

Set "Hour(s)" to (preferably) sometime in the AM, when the server load will be light, so as to make it easier on the server to process your removal.

Set "Day(s)" to a number higher than Every Day/1.  Preferably every 2 days, even better if you set it to a higher number.  This will keep your cron from causing any issues.  Better safe than flooded with spam because the cron crashed itself.

Leave "Months" alone.  It's fine where it is.

Set "Weekdays" to something that's NOT Every Weekday.

See the screenshot for an example using my account.  The cron shown here will remove the spam folder from my "trey" account on my site.  You'll want the setup to be similar.  (Note:  I'm on an EMC server, so I've got the /nfs in my path.)



9.  Then click "Save Crontab".

Now when you go into the Cron Jobs section again, you'll see that the first one is filled out with the previous information.

You'll need to set one of these up for each mail account you want the spam removed for.  It's not recommended to do with a large number of mail accounts.

===============================================


OK, now you all owe me $20.

-Trey
« Last Edit: August 25, 2005, 03:55:04 PM by Trey »
This space for rent.  Reasonable rates!

leighsww

  • Guest
How To: Remove spam automatically
« Reply #1 on: April 25, 2004, 08:06:18 PM »
Leigh drops $20 Monopoly money into Trey's tin can

Danielle

  • Guest
How To: Remove spam automatically
« Reply #2 on: April 25, 2004, 11:20:03 PM »
Ok, but if you don't want to look at the mail in the Spam Box, simply disable it and all mail marked as spam by Spam Assassin will be discarded. Anyway, that is how I would do it (I do tend to take the short cut way though), so maybe I'm missing the point  :?

/me feels bad after Trey noting people should read my how-to that was not actually written by me but by w98...

leighsww

  • Guest
How To: Remove spam automatically
« Reply #3 on: April 25, 2004, 11:26:15 PM »
LOL!

Leigh removes Monopoly money from Trey's tin can and drops it in Miraenda's tin can.

Danielle

  • Guest
How To: Remove spam automatically
« Reply #4 on: April 25, 2004, 11:30:32 PM »
Well, for consolation, I do appreciate the cron job info (and visual image provided ;)). I've never used one in Cpanel before, so I'll try it anyway just for kicks.  :thumb:

leighsww

  • Guest
How To: Remove spam automatically
« Reply #5 on: April 25, 2004, 11:40:11 PM »
Where this may be helpful, Miraenda, may be when you don't want the Spam mail to be zapped without looking at it first (disabling the Spam Box would zap without chance of examination).

But, it would save time, because instead of individually having to delete the Spam mail, you can scan down the list looking at their "Subject" and only look closer at those that you can't tell if they are Spam.

Then you just mark them all as "Read" (which can be done with one click) so that you can by-pass them when new mail comes in, then let Trey's cron job zap them all at once.

I don't use Spam-Assassin, so I can't test it to see if what I'm saying makes sense, but that's where I would think it could work and be useful :?

Or, maybe we're just trying to think of ways so that Trey is spared :cry:

Dang, we do have soft-spots in our hearts, Miraenda!  We're weak!  :cry:

(*Leigh takes back the Monopoly $$ from Miraenda and drops it back into Trey's tin cup)  :thumb:

Danielle

  • Guest
How To: Remove spam automatically
« Reply #6 on: April 25, 2004, 11:50:39 PM »
Yeah, I guess I did always have a soft spot for Curious George..,

I guess you could change the time to once a week and that way you get a longer timeperiod to look at it before it automatically gets removed. Good job on finding a use doing this leighsww. :thumb:

leighsww

  • Guest
How To: Remove spam automatically
« Reply #7 on: April 25, 2004, 11:56:26 PM »
Whew!  Trey saves face!  :yey:

(*Leigh takes the Monopoly $$ out of Trey's tin cup and drops it into her own)  :D

Offline Trey

  • Jedi
  • *****
  • Posts: 933
    • http://www.singfreemusic.com
How To: Remove spam automatically
« Reply #8 on: April 26, 2004, 06:46:53 AM »
I wrote this for a customer who wanted to know how to remove spam automatically from the spambox.

I assume that means he wanted to review the mail at least briefly before it was all deleted.  

 :thumb:
This space for rent.  Reasonable rates!

leighsww

  • Guest
How To: Remove spam automatically
« Reply #9 on: April 26, 2004, 10:22:36 AM »
:thumb:

(*Leigh gives Trey the Monopoly $$ back - BUT this is the LAST dang time it's gonna be moved around, so Miraenda, just keep quiet  :whip: !!!)

Offline w98

  • Galactic Royalty
  • *****
  • Posts: 443
    • http://iandouglas.com
How To: Remove spam automatically
« Reply #10 on: April 26, 2004, 02:06:55 PM »
ahem ... that's MY how-to on training SpamAssassin :evil:

Offline w98

  • Galactic Royalty
  • *****
  • Posts: 443
    • http://iandouglas.com
How To: Remove spam automatically
« Reply #11 on: April 26, 2004, 02:11:25 PM »
Actually, what I've been unsuccessful at doing is removing ONLY the spam messages in my spam box that score as BAYES_99 ... that way I can re-train SpamAssassin as to what IS spam if something scores BAYES_90 or BAYES_44 or whatever...

I've set up a filter but it's not working. Can anyone at LP confirm that the mail filtering, when set up, will work on ALL incoming mail, or just to every mailbox EXCEPT our spam box?

I've tried a Perl solution - opening the mailbox, and filtering everything out. The only catch so far is that if 100% of the messages are BAYES_99, the Perl module erases the mailbox. Not to mention that the Perl script runs as 'nobody' (web server user), and the mailbox is owned by something else - so even after editing it and leaving legit messages in there, no new spam will be saved.

Danielle

  • Guest
How To: Remove spam automatically
« Reply #12 on: April 26, 2004, 03:06:22 PM »
Hey w98,

I did say this above:

Quote from: Miraenda
/me feels bad after Trey noting people should read my how-to that was not actually written by me but by w98...


I haven't tried to take credit for it.  :poke:

leighsww

  • Guest
How To: Remove spam automatically
« Reply #13 on: April 26, 2004, 03:09:20 PM »
LOL ... I think w98 mentioned it again just so he could get the Monopoly $$.  BUT, I told everyone that I'm NOT moving it around anymore!!  It stays in Trey's tin cup!  :whip: He's living in dev/null, so he's homeless, he need it  :cry:

Offline w98

  • Galactic Royalty
  • *****
  • Posts: 443
    • http://iandouglas.com
How To: Remove spam automatically
« Reply #14 on: April 26, 2004, 03:20:07 PM »
aww  :-?

 

Share |