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.

Spam Folder Mismatch

Discussion in 'E-mail Discussions' started by cornfeed, Apr 1, 2013.

  1. cornfeed

    cornfeed Registered

    Joined:
    Aug 23, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I would like to document an issue I have had in the hopes of gaining enough support to see a fix.
    I will update this post if any updates arise.

    The Issue:
    When making use of the SpamAssassin Spam Box feature, Exim is configured to send everything to .spam, but Roundcube creates a default folder '.Junk' instead of matching '.spam', forcing the user to manually subscribe to the new, true, spam folder. This causes a bunch of confusion for the average user.

    Possible fix 1:
    Force the creation of the new '.spam' folder (instead of waiting for first spam) and symlink to .Junk
    Issue: clients that do not respect subscriptions will show users both folders

    Current Working Fix: (with added bonus)
    1) Turn off SpamAssassin Auto-delete
    2) Turn on SpamAssassin Spam Box

    You will now need a way to automate your users subscribing to it, moving emails, and deleting the old folder(s). This can easily be done with a roundcube plugin.

    3) Create a folder for your new plugin
    Code:
    # mkdir /usr/local/cpanel/base/3rdparty/roundcube/plugins/folderfix
    # touch /usr/local/cpanel/base/3rdparty/roundcube/plugins/folderfix/folderfix.php
    # chown -R root:wheel /usr/local/cpanel/base/3rdparty/roundcube/plugins/folderfix
    
    4) Edit /usr/local/cpanel/base/3rdparty/roundcube/plugins/folderfix/folderfix.php with your favorite editor, adding the following:
    Code:
    <?php
    /*
     * folderfix plugin
     *
     * this plugin moves emails and deletes spam folders that don't fit cPanel's .spam design
     */
    class folderfix extends rcube_plugin {
    
      public $task = 'login';
    
      function init() {
        $this->add_hook( 'login_after', array($this, 'fix_folders') );
      }
    
      function fix_folders($args) {
        $rcmail = rcmail::get_instance();
        // create special folders on every login
        $specialfolders = array( 'drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox' );
        foreach( $specialfolders as $folder ) {
          if( $rcmail->config->get($folder) ) {
            $foldername = $rcmail->config->get($folder);
            if( !$rcmail->imap->mailbox_exists($foldername) )
              $rcmail->imap->create_mailbox($foldername, true);
            else if( !$rcmail->imap->mailbox_exists($foldername, true) )
              $rcmail->imap->subscribe($foldername);
          }
        }
        if( $rcmail->imap->mailbox_exists('INBOX.Junk') ) {
          $rcmail->imap->move_message( '*', 'INBOX.spam', 'INBOX.Junk' );
          $rcmail->imap->delete_mailbox('INBOX.Junk');
        }
        else if( $rcmail->imap->mailbox_exists('INBOX.junk') ) {
          $rcmail->imap->move_message( '*', 'INBOX.spam', 'INBOX.junk' );
          $rcmail->imap->delete_mailbox('INBOX.junk');
        }
        else if( $rcmail->imap->mailbox_exists('INBOX.Spam') ) {
          $rcmail->imap->move_message( '*', 'INBOX.spam', 'INBOX.Spam' );
          $rcmail->imap->delete_mailbox('INBOX.Spam');
        }
        return $args;
      }
    }
    
    5) Edit /usr/local/cpanel/base/3rdparty/roundcube/config/main.inc.php to match the following:
    Code:
    ...
    $rcmail_config['junk_mbox'] = 'INBOX.spam';
    ....
    $rcmail_config['plugins'] = array('cpanellogin','cpanellogout','folderfix');
    ...
    Now, when a user logs in, the script will check to make sure the user has and is subscribed to all the "special folders" (drafts, sent, etc)

    Obviously cPanel is going to write over all this upon update, so we need to follow the official guide for deploying a custom roundcube package.

    I plan to look into a command line solution for all those Mac Mail/Thunderbird/etc users.
    Check back for updates and help me make this a known issue... maybe they will put out an official fix :)
     
    #1 cornfeed, Apr 1, 2013
    Last edited: Apr 1, 2013
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,468
    Likes Received:
    196
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello, the attachment has been removed.

    Please feel free to submit your suggestions as a Feature Request here:
    cPanel Feature Requests
    Or to the cPanel Application Catalog located here:
    cPanel App Catalog
     
  3. cornfeed

    cornfeed Registered

    Joined:
    Aug 23, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Thank you for taking a look at my thread.
    Why was the file removed? Did I violate a policy? I can link to at offsite server if you would like...
    Further, this is flat out a bug, not a feature request or addon advertisement.

    Thanks,
    cornfeed
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,468
    Likes Received:
    196
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  5. andryan

    andryan Member

    Joined:
    Apr 23, 2005
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hi cornfeed,

    Did you log this as a bug report?
     
Loading...

Share This Page