• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

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 [email protected] -mailbox false
/usr/local/psa/bin/mail --update [email protected] -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