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.

How to mark a single message as Spam in Horde

Discussion in 'Workarounds and Optimization' started by Spork Schivago, Jun 4, 2017.

Tags:
  1. Spork Schivago

    Spork Schivago Well-Known Member

    Joined:
    Jan 21, 2016
    Messages:
    462
    Likes Received:
    52
    Trophy Points:
    28
    Location:
    corning, ny
    cPanel Access Level:
    Root Administrator
    I was searching Google on how to mark an individual item as Spam in Horde using cPanel. The first query leads me to cpanel.net's e-mail discussion forum where someone asked the question and was told it wasn't possible. I figured I'd let you know that this is possible to do with Horde and cPanel, just in case anyone else comes here looking for the answer and thinks it cannot be done. It does involve a little bit of work. This is how I did it:

    We need to create a Horde overlay file so when cPanel updates Horde, our changes to the configuration file doesn't get erased. I did this by creating the appropriate directories under the /tmp/ directory (via an SSH shell).
    Code:
    mkdir -p /tmp/horde/imp/config
    
    Then I created the backends.local.php file under that directory:
    Code:
    nano -w /tmp/horde/imp/config/backends.local.php
    
    I added this to that file (you can just copy and paste it)
    Code:
    <?php
    
    // IMAP server
    $servers['imap'] = array(
        // Disabled, we will use the Advanced IMAP Server instead
        'disabled' => true,
        'name' => 'IMAP Server',
        'hostspec' => 'localhost',
        'hordeauth' => 'full',
        'protocol' => 'imap',
        'port' => 143,
        // Plaintext logins are disabled by default on IMAP servers (see RFC 3501
        // [6.2.3]), so TLS is the only guaranteed authentication available by
        // default.
        'secure' => 'tls',
    );
    
    // POP3 server
    $servers['pop'] = array(
        // Disabled by default
        'disabled' => true,
        'name' => 'POP3 Server',
        'hostspec' => 'localhost',
        'hordeauth' => false,
        'protocol' => 'pop',
        'port' => 110,
        // Default to secure TLS authentication by default (see RFC 2595 [4]).
        'secure' => 'tls',
    );
    
    // Advanced IMAP Server
    $servers['advanced'] = array(
        // Enabled (with 'Spam' button)
        'disabled' => false,
        'name' => 'Advanced IMAP Server',
        'hostspec' => 'localhost',
        'hordeauth' => 'full',
        'protocol' => 'imap',
        'port' => 143,
        'secure' => 'tls',
        'maildomain' => '',
        'smtp' => array(
        //    'auth' => true,
        //    'debug' => false,
        //    'horde_auth' => false,
        //    'host' => 'smtp.example.com',
        //    'localhost' => 'localhost',
        //    'password' => null,
        //    /* Mail from a MUA SHOULD be sent via the mail submission port (587)
        //    * rather than the MTA port (25). Note that mail submission
        //    * REQUIRES some method of authentication (whether explicit
        //    * user/password credentials or configuring the mail submission
        //    * agent to automatically authenticate this host based on the
        //    * network location). */
        //    'port' => 587,
        //    'username' => null
        ),
        'spam' => array(
               'innocent' => array(
                   'display' => true,
            //
            //     // Email reporting driver
            //     'email' => null,
            //     'email_format' => 'digest',
            //
            //     // Null reporting driver
            //     'null' => true,
            //
            //     // Program reporting driver
                   'program' => '/usr/local/cpanel/3rdparty/bin/spamc -C revoke -u %l',
               ),
               'spam' => array(
                   'display' => true,
            //
            //     // Email reporting driver
            //     'email' => null,
            //     'email_format' => 'digest',
            //
            //     // Null reporting driver
            //     'null' => true,
            //
            //     // Program reporting driver
                   'program' => '/usr/local/cpanel/3rdparty/bin/spamc -C report -u %l',
               ),
            // // It is possible to directly define additional spam drivers.
            // // The 'drivers' array should contain a list of driver objects
            // // (these classes must implement the IMP_Spam_Base class).
            // 'drivers' => array(
            //    new IMP_Example_Spam_Driver()
            // )
        ),
        'admin' => array(
        //    'user' => 'cyrus',
        //    'password' => 'cyrus_pass',
        //    'userhierarchy' => 'user.'
        ),
        'acl' => true,
        'cache' => false,
        // 'debug' => '/tmp/imp_imap.log',
        // 'debug_raw' => false,
        'quota' => array(
            'driver' => 'imap',
            'params' => array(
                'hide_when_unlimited' => true,
                'unit' => 'MB'
            )
        ),
        'special_mboxes' => array(
              IMP_Mailbox::MBOX_DRAFTS => 'INBOX.Drafts',
              IMP_Mailbox::MBOX_SENT => 'INBOX.Sent',
              IMP_Mailbox::MBOX_SPAM => 'INBOX.Spam',
        //    IMP_Mailbox::MBOX_TEMPLATES => 'INBOX.Templates',
              IMP_Mailbox::MBOX_TRASH => 'INBOX.Trash',
        //      IMP_Mailbox::MBOX_USERSPECIAL => array(
        //          'Example' => _("Example Special Mailbox")
        //      )
        ),
        'autocreate_special' => true,
    );
    
    You can save the file (ctrl-x and then 'y' when it asks if you want to save). After that, you need to copy the file to the horde config directory for changes to take effect.
    Code:
    cp -p /tmp/horde/imp/config/backends.local.php /usr/local/cpanel/base/horde/imp/config/
    
    Afterwards, log into your Horde webmail user interface to make sure it's working. If it's not, double check everything or write here. If it does work, then you need to create the overlay.tar.gz file and copy it to the /var/cpanel/horde/ directory
    Code:
    cd /tmp
    tar -czvf /var/cpanel/horde/overlay.tar.gz horde
    
    When cPanel updates Horde, it'll first remove the /usr/local/cpanel/base/horde directory, replace it with the new version, and then uncompress the overlay.tar.gz archive into the /usr/local/cpanel/base/horde directory. Your backends.local.php file will be put into that directory and you should always see the button in Horde to report individual and selected e-mails as Spam.

    The last step you should take is cleaning up the /tmp directory.
    Code:
    rm -rf /tmp/horde
    
    I hope this helps other cPanel users who come here looking for a way to add the Spam button.

    I'd like to add that I got the format of the backends.local.php config file from the Horde mailing list. I just modified it a bit to work with cPanel.

    Thanks!
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,037
    Likes Received:
    1,278
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Thank you for providing the workaround. I've moved this thread to our "Workarounds" forum. You may also want to open a feature request if you'd like to see this functionality included with the version of Horde provided with cPanel:

    Submit A Feature Request


    Thanks!
     
  3. Spork Schivago

    Spork Schivago Well-Known Member

    Joined:
    Jan 21, 2016
    Messages:
    462
    Likes Received:
    52
    Trophy Points:
    28
    Location:
    corning, ny
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page