• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

How to auto-empty a specific mailbox daily?

Pagemakers

Silver Pleskian
Is there any way to auto-delete all the messages in a specific mailbox on a specify domain on a daily basis?

Using Postfix.
 
This would need to be done via ssh

You would need a script to do it:

Code:
#!/bin/bash

# Specify the domain name used for the email address
DOMAIN="example.com"

# Specify the local part of the email address
MAILBOX="mailbox"

# Find only files in the new directory and delete them
find /var/qmail/mailnames/$DOMAIN/$MAILBOX/Maildir/new/ -type f -delete

#Enable this string to delete files in the cur directory too
find /var/qmail/mailnames/$DOMAIN/$MAILBOX/Maildir/cur/ -type f -delete

#Alternative way if the above isn't performing well, however as this is using "rm -rf" I think its a bit dangerous
#find /var/qmail/mailnames/$DOMAIN/$MAILBOX/Maildir/new/ -type f -exec rm -rf {} \;

You can add this into your server and then create a cronjob to run it at the times you require.
 
Additionally:

You can delete the mailbox (and thus all the emails inside it) and recreate it via the command line - this may be safer but depending on the size of the mailbox may be rather slow.

Create a script to run the following commands:

Code:
/usr/local/psa/bin/mail --update test@example.com -mailbox false
/usr/local/psa/bin/mail --update test@example.com -mailbox true

Deleting the mailbox this way does not change the password for the mailbox, as it continues to exist with the password table (tested on my Plesk 11.5 server)
 
Thank you. Your second options seems simpler. I guess there will only be a couple of MB per day to delete. I’m on 11.5 too
 
Back
Top