by Devin Yang

建立於: 3年前 ( 更新: 3年前 )

收信的信箱爆了,所有的信都不想要,用PHP清空收件夾。
以下是我抄來的範例程式,做了小調整。
<?php
$imap_server="{www.hibox.hinet.net:993/imap/ssl}INBOX";

$mbox = imap_open($imap_server, "信箱帳號", "密碼")
    or die("Can't connect: " . imap_last_error());

$check = imap_mailboxmsginfo($mbox);
echo "Messages before delete: " . $check->Nmsgs . "<br />\n";

//標記刪除
imap_delete($mbox, "1:$check->Nmsgs");

$check = imap_mailboxmsginfo($mbox);
echo "Messages after  delete: " . $check->Nmsgs . "<br />\n";

imap_expunge($mbox);

$check = imap_mailboxmsginfo($mbox);
echo "Messages after expunge: " . $check->Nmsgs . "<br />\n";

imap_close($mbox);
執行後就被清的一乾二淨:p

不過PHP,PHP沒有imap的擴充,我套過docker輕鬆擴充有imap的php。
我使用的是D-Laravel的Dockerfile,補上相關的套件,再重build dockerfile。
一、加入套件:
libc-client-dev libkrb5-dev \
二、加入config 
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
三、補上imap。
RUN docker-php-ext-install -j$(nproc) pdo_mysql mysqli ldap pgsql pdo_pgsql gettext sockets imap ctype xml zip pcntl bcmath intl gd \
以下附下git版控顯示的差異。



 

Tags: php

Devin Yang

文章內容無法一一說明,如果您有什麼不了解處,歡迎提問哦:)

No Comment

Post your comment

需要登入才可留言!

類似的文章


php, CentOS, phpize

在舊版的CentOS上找不到phpize,無法編譯php擴充。

在舊版的CentOS上找不到phpize,無法編譯php擴充。 如何安裝phpize呢?

php

如何在舊版的CentOS 5.11安裝PHP 7.1.7呢?

如何在舊版的CentOS 5.11安裝PHP 7.1.7呢? 自行編譯時發生了insfinit錯誤,本文介紹我的方式。

php

淺談PSRs

PSR全稱叫做「PHP標準建議」(PHP Standards Recommendations)。由FIG(PHP框架互用性群組)所制定的建議規範, 這個群組是在2009年的php|tek由一些框架的開發者發起的,由最初的5個到現在已超出20多個了。 在「PHP標準建議」中有很多的編號,每個編號代表了不同的規範。