How to empty mailboxes in same domain

Discussion in 'General' started by Pedro A., Nov 14, 2022.

  1. Pedro A.

    Pedro A. Member

    Hi!
    I've some mail accounts own to the same domain and I want to clear all emails from them (not the account). It's possible?
    i.e. I've: [email protected], [email protected], [email protected] and [email protected]. I want to empty all emails from mailboxes person1 to person3. I don't know if it's possible without deleting the account and reconfig.
    Thanks.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Probably the easiest way is to use your mail client, use the mail clients search function to select emails and then move them to junk folder and empty junk folder.
     
  3. Pedro A.

    Pedro A. Member

    I've each account configured in single computers (one account, one pc), then I'd to move from each computer to another. I've 30 accounts aprox.
    I'd like to avoid that, ;)
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Then you'll probably have to write a script or program (or find one if someone has written such a thing already) which opens each mailbox via IMAP protocol (or alternatively opens each mail file and parses it for the from and to headers), checks each mail for the criteria you want to filter mails for deletion, and then removes them via IMAP delete command.
     
  5. Pedro A.

    Pedro A. Member

    Naaa, finally I deleted all accounts an recreate them.
    This functionality could be added in future versions ;). And a checkbox could be added too that allow selecting some mailboxes and deleting them.
    Thanks.
     
  6. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    Code:
    doveadm expunge -u [email protected] mailbox 'INBOX' all
    doveadm expunge -u [email protected] mailbox 'INBOX.*' all
    
    1st line deletes all mail from the inbox, 2nd line deletes mail from all folders except the inbox.
     
    Pedro A. likes this.
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    But that's not what you initially asked for, as far as I can see from your first post. Your initial question was to delete just specific emails based on the sender and not to empty a complete mailbox. Emptying a mailbox is easy and explained by @nhybgtvfr while deleting just some emails depending on the sender is not.
     
    Pedro A. likes this.
  8. Pedro A.

    Pedro A. Member

    Thanks for the answers.
    I'll try the @nhybgtvfr solution.
    Sorry about my original post if it was misunderstood.
    I said "want to empty all emails from mailboxes person1 to person3" not certain emails. I should use: empty the complete mailboxes.
    Sorry.
     
    till likes this.
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Thank you for the clarification. I thought you wanted to remove only emails sent from person1 to person3.
     

Share This Page