The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Auto-deletion of emails

Discussion in 'E-mail Discussions' started by cag8f, Jul 25, 2014.

  1. cag8f

    cag8f Member

    Joined:
    Jul 25, 2014
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi all. New cpanel user and first post here.

    Is there a method built-in to cpanel that can auto-delete my emails after X days? Or is this something I would have to create a CRON job to carry out?

    Thanks in advance.
     
  2. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    817
    Likes Received:
    22
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
  3. cag8f

    cag8f Member

    Joined:
    Jul 25, 2014
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Great I'll give that a read--thanks!
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Note that if you want the "Trash" email automatically deleted, you can browse to:

    "WHM Home » Service Configuration » Mailserver Configuration"

    There is an option titled "Auto Expunge Trash" if you are using Dovecot, or an option called "IMAP Empty Trash" if you are using Courier.

    Thank you.
     
  5. marcochiesi

    marcochiesi Member

    Joined:
    Mar 1, 2011
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Italy
    cPanel Access Level:
    Root Administrator
    Twitter:
    Does the "Auto Expunge Trash" option also act on the accounts spam folders?
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You can edit the following file for local modifications to the Dovecot configuration:

    Code:
    /var/cpanel/templates/dovecot2.2/main.local
    Note: You can copy this file from /var/cpanel/templates/dovecot2.2/main.default if it does not exist. The relevant section here is:

    Code:
    [% IF expire_trash %]
      expire_dict = proxy::expire
      expire = Trash
      expire2 = "Deleted Messages"
      expire3 = "INBOX.Deleted Messages"
      expire4 = INBOX.Trash
    You can add additional mailbox names to this section (e.g. Junk). After making the custom modifications, you must run:

    Code:
    /scripts/builddovecotconf
    Thank you.
     
  7. marcochiesi

    marcochiesi Member

    Joined:
    Mar 1, 2011
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Italy
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi Michael,
    thanks a lot for your reply, it was exactly what I was looking for.... unfortunately I was not able to let it work.
    As you suggested I made a copy of /var/cpanel/templates/dovecot2.2/main.default to /var/cpanel/templates/dovecot2.2/main.local and I made the following changes:
    Code:
    [% IF expire_trash %]
      expire_dict = proxy::expire
      expire = Trash
      expire2 = "Deleted Messages"
      expire3 = "INBOX.Deleted Messages"
      expire4 = INBOX.Trash
      expire5 = Junk
      expire6 = Spam
      expire7 = spam
      expire8 = INBOX.Junk
      expire9 = INBOX.Spam
      expire10 = INBOX.spam
    
    [% END %]
    
    Then I run
    Code:
    /scripts/builddovecotconf
    which had the following output
    Code:
    info [builddovecotconf] 'local' template in use (/var/cpanel/templates/dovecot2.2/main.local)
    I suppose there's a cPanel nightly task that calls this procedure, but it did not delete old spam messages last night.
    I also tried to manually run
    Code:
    /scripts/maintenance
    which had this in its log
    Code:
    ...
    [20141002.091305]   Processing: Cleaning up mailbox trash
    [20141002.091305]    - Processing command `/usr/local/cpanel/scripts/dovecot_auto_expunge_trash`
    ...
    
    but spam messages are still there.

    By the way, inside the dovecot config file a comment says:
    Code:
      # Expire plugin. Mails are expunged from mailboxes after being there the
      # configurable time. The first expiration date for each mailbox is stored in
      # a dictionary so it can be quickly determined which mailboxes contain
      # expired mails. The actual expunging is done in a nightly cronjob, which
      # you must set up:
      #   dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool
    
    but if I try to run
    Code:
    dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool
    I get
    Code:
    Fatal: Unknown argument: --exec-mail
    I suppose it was for an old dovecot version.

    Any ideas?
     
    #7 marcochiesi, Oct 2, 2014
    Last edited: Oct 2, 2014
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Do you notice any output when running "/scripts/dovecot_auto_expunge_trash" directly? Have you moved new email to the Trash or SPAM directories since making the change and has it passed the expire time?

    Thank you.
     
  9. marcochiesi

    marcochiesi Member

    Joined:
    Mar 1, 2011
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Italy
    cPanel Access Level:
    Root Administrator
    Twitter:
    The "/scripts/dovecot_auto_expunge_trash" gives no output, but your words made me think... Many old messages were recently moved to Trash/Spam folders. I thought they would have been deleted since they were pretty old, but it makes sense that the 30 days are counted starting from the date of deletion and not from the date of the message. So I suppose they will be deleted in a month or so.
    By the way, is there a way to get the deletion date of a message?
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  11. mcpacific

    mcpacific Member

    Joined:
    May 3, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Los Angeles, CA
    cPanel Access Level:
    Root Administrator
    I have been having problems with this myself. Under WHM » Service Configuration » Mailserver Configuration I have set Auto Expunge Trash [checked] and set Trash Expire Time to be 10. Also, my dovecot.conf file includes the following:

    Code:
      expire_dict = proxy::expire
      expire = Trash
      expire2 = "Deleted Messages"
      expire3 = "INBOX.Deleted Messages"
      expire4 = INBOX.Trash
      expire5 = Junk
      expire6 = INBOX.Junk
    
    Yet, Trash and Junk never auto expunge. I ran the following script manually, however, and it cleaned one of my Trash folders on one email account (the Junk folder was NOT auto expunged):

    Code:
    /scripts/dovecot_auto_expunge_trash
    
    Other than checking the setting in Mailserver Configuration, do I need to manually add a cron job? What do I do about the Junk folders? I'm using WHM 11.48.
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  13. mcpacific

    mcpacific Member

    Joined:
    May 3, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Los Angeles, CA
    cPanel Access Level:
    Root Administrator
    Yes, precisely.
     
  14. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
Loading...

Share This Page