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.

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

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么