doubo7131 2017-09-06 09:23
浏览 19
已采纳

用PHP获取Plesk邮箱信息?

I have set some mail quota's on email addresses that I manage through Plesk.

However, users are complaining that they are not being informed when their inbox is full or nearly full.

So my idea was to send an email to them when their inbox is about 90% full, so I was wondering if I can retrieve mail account information using PHP?

If not, is there another way of doing this? (I'm not too familiar with console commands)

  • 写回答

1条回答 默认 最新

  • dongyan5141 2017-09-06 10:02
    关注

    In this answer I skip the Plesk API altogether, and I assume you either store the properties of the mailboxes in a database, hardcode it, or actually use the Plesk API to retrieve it.

    Here is how I retrieve the space used by a mailbox:

    function getSpaceUsedByMailBox($username,$password)
    {
      // open mailbox
      $mailBox = imap_open('{localhost:110/pop3/novalidate-cert}INBOX',$username,$password);
      // test if successful
      $errors = imap_errors();
      if ($errors === FALSE)
      {
        // get info
        $info = imap_mailboxmsginfo($mailBox);
        // give feedback
        echo "Mailbox of $username contains ".$info->Nmsgs.
             ' messages and is '.$info->Size.' bytes big.';
        // flush notices
        imap_errors();
        imap_alerts();
        // close mailbox
        imap_close($mailBox);
        // return info
        return $info;
      }
      // change this to proper error handling
      echo 'ERROR: '.print_r($errors);
      // return nothing
      return NULL;
    }
    

    This is just to give you an idea. You have to adapt it to your coding style.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?