System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Removing mails more than 1 day

Henry Chua
Super Advisor

Removing mails more than 1 day

Hi guys,

I am using sendmails in my box, is there a way to remove mails more than a specified period of time? Thanks.

Best regards
Henry
3 REPLIES
Steven E. Protter
Exalted Contributor

Re: Removing mails more than 1 day

Shalom Henry,

That depends how you store them. If they are sitting in a file in /var/spool/mail raw, its difficult. You'd need to write a script to edit that file.

Need to know a little more about how the mail is stored to assist you.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: Removing mails more than 1 day

The important thing here is which MTA are you using (qmail, sendmail, postfix, exim, etc).

See this page:

http://ftp.ccs.neu.edu/pub/CPAN/scripts/mailstuff/expire_mail.pl
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Emir Faisal
Frequent Advisor

Re: Removing mails more than 1 day

Hi,
...or you might want to change your sendmail behavior by set the Timeout.queuereturn to 1 day in your sendmail.mc or sendmail.cf. This behavior will send bounced message to sender if the message stay in the queue after 1 day.

for sendmail.mc:
dnl define('confTO_QUEUERETURN', '1d')dnl
then run m4 macro to regenerate sendmail.cf and put it in the right location (/etc/sendmail.cf ?).

for sendmail.cf:
O Timeout.queuereturn=1d



either way, don't forget to restart sendmail daemon.

EF
Everything is possible, if you don't know what you're talking about.