Delete All Default Email Address for All Users

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

Email sent to the default address is stored in:
Code:
/home/$username/mail/cur
/home/$username/mail/new
You can delete all of this email through the use of a wildcard and the "rm" command.

To note, you can ensure emails sent to non-existent email accounts are not delivered to the default address by ensuring your accounts set the "Default Address" to:

"Discard with error to sender (at SMTP time)"

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
There is no single command to use, but you could try something such as:

Code:
mkdir /root/email-to-delete
mv /home/*/mail/cur/* /root/email-to-delete/
mv /home/*/mail/new/* /root/email-to-delete/
Then, simply delete "/root/email-to-delete" when you have confirmed the emails are no longer required.

Thank you.
 

gfserver

Active Member
Feb 18, 2015
27
4
53
cPanel Access Level
Root Administrator
Hi.. I've tried this method but I received this message
-bash: /bin/mv: Argument list too long

What can I do? I'm a newbie

Apologize my bad english

Thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
I don't suggest using these types of commands if you are an inexperienced user. Have you checked to see if your hosting provider or data center can assist you with this? If they can't help you, try these commands:

Code:
mkdir /root/email-to-delete
find /home/*/mail/cur/* -type f | xargs -i mv "{}" /root/email-to-delete/
Remember this is going to remove all email from every account's default address.

Thank you.