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.

Modify email usage with CustomEventHandler or anything else ?

Discussion in 'cPanel Developers' started by tizoo, Jun 10, 2011.

  1. tizoo

    tizoo Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    Hi all,

    CustomEventHandler and the PublicAPI give us a great flexibility to retrieve information or even modify the behavior of events in cPanel.

    For what I'm currently doing, I need to manually modify the email usage of the mailbox because they are in another server.

    I thought using Email::getdiskusage in CustomEventHandler with a *pre* event to manually modify the values but the tests I have done show me that it's not the right function that is normally called every 4 hours to recalculate the email usage. But maybe I just missed something.

    I have then the following questions :

    * Could I modify the email usage with CustomEventHandler ?
    * If yes, which one is the right function to call if it's not Email::getdiskusage ?
    * If no, is it possible with the PublicAPI ?
    * And if not ... Is there another way to achieve this, for example by manually modifying the right files ? In fact, what are those files ?

    Thanks a lot in advance for any tips.

    Philippe
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I'm glad to see you are doing this. There are a few different concerns that I have.

    What specifically are you trying to change? Is this in the email page?
     
  3. sirdopes

    sirdopes Well-Known Member
    PartnerNOC

    Joined:
    Sep 25, 2007
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    16
    From what you are describing, it sounds like it would be better to write a custom cpanel plugin that uses the api to pull the disk usage off of the remote server. I don't think that there is going to be an easy way to accomplish this on the cpanel page. I haven't really looked into this but the only way that I could see this working is if you modify the disk usage cache file, assuming this is actually cached, and the user has permission to modify this file in the first place.
     
  4. tizoo

    tizoo Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    Hi all,

    @ cPanelMatt :

    I want that the *Usage/Quota* column in the *Email Accounts* page shows for each email account the real usage of the mailbox which is on another server.

    As the email quota is recalculated every 4 hours (with /scripts/quotacheck I guess) I though that I could overwrite the calculated quota for mailboxes (only for mailboxes, not for the full account) with the value from the other server. And then the right usage of the mailboxes will be shown in the *Email Accounts* page in cPanel.

    @sirdopes

    The first idea is using *CustomEventHandler* which could maybe let me modify the value before they are set in the cache file or somewhere else. But I don't think it's possible as I guess it won't be possible either with *pre* nor *post* events, but with something like a *middle* event. The other problem is that *CustomEventHandler* is run as the user and if the cache file to modify is not in the home directory, *CustomEventHandler* will be useless.

    Then I though using *function hooks* that run as root. In this way I would be able to modify the usage/cache file.

    As I never wrote a cpanel plugin I don't know if this would give me more functionalities then hooks or CustomEventHandler. Is that right ?


    Thanks in advance for any response or any idea.

    Philippe
     
  5. tizoo

    tizoo Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    Hi all,

    I guess I made some errors when checking the way the *maildirsize* file works as I thought it wasn't the file I needed. But now I do some more tests I think that I just have to modify this file to have it reflect the usage of the mailbox.

    Thanks a lot for your responses and have a nice week.

    Philippe
     
Loading...

Share This Page