Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Delete inbox via SSH?

Discussion in 'E-mail Discussion' started by Web Sol, Nov 16, 2018.

  1. Web Sol

    Web Sol Registered

    Joined:
    Oct 30, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Romania
    cPanel Access Level:
    Root Administrator
    I want to delete all emails received in my email address directly from ssh.

    How to do that?

    Thanks!
     
  2. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,484
    Likes Received:
    187
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    find /home/<username>/mail/<domain.com>/<emailuser>/new/ -type f -print -delete

    find /home/<username>/mail/<domain.com>/<emailuser>/cur/ -type f -print -delete

    Best to make a backup of the account just in case.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,504
    Likes Received:
    2,179
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Web Sol,

    You can use the following WHM API 1 or UAPI functions to remove emails via the command line:

    WHM API 1 Functions - expunge_mailbox_messages - Developer Documentation - cPanel Documentation
    UAPI Functions - Mailboxes::expunge_mailbox_messages - Developer Documentation - cPanel Documentation

    For example, you'd use a WHM API 1 command like this to delete all emails older than 1 week within an email account's INBOX folder:

    Code:
    whmapi1 expunge_mailbox_messages [email protected] mailbox=INBOX query="savedbefore%201w"
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice