LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash script to process mail queue (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-to-process-mail-queue-746054/)

Zealus.com 08-08-2009 11:26 AM

Bash script to process mail queue
 
Hi all (my first post here)!

I look after a few CentOS servers, and since I am not a Linux guru some things get out of hand eventually. One of the things that has been bothering me for quite some time is mail queue.

On any average day I see around a hundred messages sitting in the queue, 99.99% of them are spam or bounces (mailbox doesn't exist, mailbox full, etc.) Some of these e-mails are sitting there for as long as few days (don't know if it affects the server, but it annoys the hell out of me). What I am looking for is either a setting or help on a bash script to rid of anything that sits there for longer then 48 hours. So far I have found that sendmail -bp lists all the e-mails in the queue but I don't really know how to parse it using bash.

Next part is /var/spool/exim/scan folder. I assume it's a part of the queue, therefore I am making it a part of the question. I see a bunch of files and folders going all the way back to 2007 (which is when the server was built). From the name I guess it's a temp folder for scanning incoming and outgoing e-mails so it has to get cleared once the scanning complete. Since it doesn't happen I would also appreciate a setting or help with a script that clears that out. Since the structure of this folder is pretty weird to me (it goes by numbers and letters of the alphabet in both cases, that in turn contain eml files) I am reluctant to just delete them since I suspect there's a database somewhere that keeps track of these things.

If you have an answer to any of these feel free to elaborate as much as possible - I'd rather read again something I already know than miss something I have no clue about.

jstephens84 08-08-2009 09:40 PM

Try looking into assassin this should help with your spam issue. You may also want to look into another product like barracuda which can help with spam also.

Zealus.com 08-08-2009 11:28 PM

Quote:

Originally Posted by jstephens84 (Post 3636232)
Try looking into assassin this should help with your spam issue. You may also want to look into another product like barracuda which can help with spam also.

Hope you will not get offended if I point that your answer has nothing in common with what I was asking about. I do have SA running and it does its job well enough (although the strain on server gets so heavy that I am thinking about turning it off at least for some of the accounts.

My question(s) are mostly about settings and shell scripting, not about spam issues.

Thank you for understanding.

jstephens84 08-08-2009 11:43 PM

Quote:

Originally Posted by Zealus.com (Post 3636282)
Hope you will not get offended if I point that your answer has nothing in common with what I was asking about. I do have SA running and it does its job well enough (although the strain on server gets so heavy that I am thinking about turning it off at least for some of the accounts.

My question(s) are mostly about settings and shell scripting, not about spam issues.

Thank you for understanding.

None takin. I offered those as suggestions as to a solution that would stop spam before it even got to your server.

However yes you can use a shell script with cron and clean the folder up. I will try to cook something up and post back when I have something that works. Unless some one beats me.

jstephens84 08-10-2009 10:22 AM

Ok so I did find a starting point. if you used the command
Code:

find /var/log/mail -atime -2
it would search the /var/log/mail directory for anything older than two days. it will also go below any directory in mail so you may want to look here to stop going down the folder level.

http://linux.die.net/man/1/find

that should get you started.


All times are GMT -5. The time now is 06:23 PM.