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!

UAPI store_filter doesn't create filter.yaml for email user

Discussion in 'cPanel Developers' started by ipublicis, Apr 19, 2019.

Tags:
  1. ipublicis

    ipublicis Member

    Joined:
    Apr 27, 2018
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Lisboa, Portugal
    cPanel Access Level:
    Root Administrator
    I'm having a problem creating SPAM filters when creating new email users.

    I use the following code:

    private function addFilters($completeMail, $email) {

    $this->cPanel->uapi->Email->add_spam_filter([ "account" => $completeMail ]);

    $this->cPanel->uapi->Email->store_filter([
    'filtername' => 'SPAM',
    'account' => $completeMail,
    'action1' => 'save',
    'dest1' => '$home/mail/quercus.pt/'.$email.'/.spam',
    'part1' => '$h_X-Spam-Status:',
    'match1' => 'begins with',
    'val1' => 'Yes',
    'opt1' => 'or',
    'part2' => '$h_X-Spam-Score:',
    'match2' => 'is above',
    'val2' => '4',
    'opt2' => 'or',
    'part3' => '$h_X-Spam-Bar:',
    'match3' => 'contains',
    'val3' => '++++'
    ]);
    }

    Assuming $completeMail = teste21@mydomain.com and $email = teste21:
    1. the .spam folder is not generated
    2. This is the contents of
      cat /home/username/etc/mydomain.com/teste21/filter.yaml
      ---
      filter: []

      max_allowed_spam_score: 5
      version: '2.2'
    What is missing here?

    Thanks in advance.
     
    #1 ipublicis, Apr 19, 2019
    Last edited: Apr 19, 2019
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,009
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @ipublicis,

    Can you confirm if your aim is to automatically setup a SPAM folder when new email accounts are created? If so, cPanel & WHM version 80 includes a new feature to do this for you. The following section of the cPanel & WHM Version 80 Release Notes explains how it works:

    Since the update to version 80 will automatically create spam folders for all existing email accounts that do not already have them, you won't have to setup a post email account creation hook for this purpose.

    Note that cPanel & WHM Version 80 is currently published to the EDGE release tier and is not yet ready for production servers. You can read about release tiers and release schedules on the following document:

    Product Versions and the Release Process - cPanel Knowledge Base - cPanel Documentation

    Let me know if this helps.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. ipublicis

    ipublicis Member

    Joined:
    Apr 27, 2018
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Lisboa, Portugal
    cPanel Access Level:
    Root Administrator
    Hi @Michael,

    Yes. I want to create a SPAM folder and also to filter all incomming SPAM to be delivered to that folder.

    We use on the server the version 78 -- and I don't control that -- so I do need to create it and to activate the filters :)

    Thank you.
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,009
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @ipublicis,

    Can you open a support ticket so we can take a closer look and see why the store_filter UAPI function isn't properly storing the filter rules? You can post the ticket number here and we'll link this thread to it.

    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