How to keep only mails that are 0 to 2 months old with QMAIL!
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to keep only mails that are 0 to 2 months old with QMAIL!
Hi all,
I wish to keep mails that are 0 to 2 months old on my server,then let my server auto delete them when they get older than two months,with Qmail.
Any ideas?
Although I don't do what you are tryinng to do, I run a cron job that goes and "reads" all the messages in my spam folder, cleans a backup folder (created with maildrop), etc.
I'm sure you could do the same, running find, or similar to delete based on age.
#!/bin/sh
#find will look for mails last accessed two months and 5 days ago and delete them.
find /var/maildir -atime 65 -execdir rm -f {} /;
#end of script
But I was thinking,what if some guy after haven accessed the mail,checks it again say two days before the cronjob is executed,that mail will not be deleted.
Does anyone know of a way to help with this problem?
The problem is,the "-atime n" option to find looks for files last accessed n*24hrs.Now what if someone goes back to a mail that is already 2months old,say two days from the cronjob,it means the mail will not be deleted.Though it is two months old.
Hope you understand now?
Hi Billy,
Thanks for that idea.But my problem still remain unsolved.Remember "atime n" is looking for last accessed files.We're assuming that when a mail is read,that is the last accessed time,and so our little script will find it and delete it.What if,that mail is re-read after say a month from the day it was first read?Wouldn't the time counter be reset for that mail?Instead for the mail to be a month old,it will be just a day old!
I don't know if you get me?
That may be it.I understand an unread mail has a tag which is changed when the mail is read.That should be the modify time.Even if the mail is re-read,the tag still remains as read.
Thanx.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.