How to Delete Old Emails From Plesk Qmail

Updated April 17, 2017

If you run Plesk on your server, your server e-mail runs through Qmail. This program comes with Plesk and can be controlled from the Plesk dashboard. As e-mails build up, your server may start to slow down. You should periodically delete old messages from Qmail to free up space and allow the server to run smoothly. You can delete e-mails according to their dates.

Open the Plesk dashboard (contact your server admin if you are not sure how to access it).

Click "Qmail."

Click "Run script."

Copy and paste the following into the text window:

cd /var/qmail/mailnames; IFS="@"; \

while read LINE ; do ADDR=( ${LINE} ); echo "${ADDR[0]}@${ADDR[1]}"; find ${ADDR[1]}/${ADDR[0]}/Maildir/ ( -path "/cur/" -o -path "/new/" ) ! -type d -mtime +XXXXXX | while read FILE; do DIR=$( dirname ${FILE} ); mkdir -p /path/to/dst/${DIR}; mv ${FILE} /path/to/dst/${DIR}; done; done < /path/to/address_file

Replace "XXXXXX" with the number of days of e-mail you wish to keep. For instance, if you want to delete all e-mail older than a week, put in "7." If you want to delete all e-mail older than a year, put in "365."

Click "Run."

Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Based in New York City, Ray Padgett has been writing about music and technology since his 2009 graduation from Dartmouth College. He has a degree in religion, with a minor in English. He has been published in and in "The Celebrity Café," "The Noise" and an upcoming Bob Dylan anthology.