代码之家  ›  专栏  ›  技术社区  ›  Aaranihlus

使用PHP获取Plesk邮箱信息?

  •  0
  • Aaranihlus  · 技术社区  · 7 年前

    我在通过Plesk管理的电子邮件地址上设置了一些邮件配额。

    然而,用户抱怨说,他们的收件箱已满或快满时没有收到通知。

    所以我的想法是在他们的收件箱大约90%满的时候给他们发送一封电子邮件,所以我想知道我是否可以使用PHP检索邮件帐户信息?

    1 回复  |  直到 7 年前
        1
  •  1
  •   KIKO Software    7 年前

    在这个回答中,我完全跳过了Plesk API,我假设您要么将邮箱的属性存储在数据库中,对其进行硬编码,要么实际使用Plesk API来检索它。

    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;
    }
    

    这只是给你一个想法。您必须使其适应您的编码风格。