by Devin Yang
(This article was automatically translated.)

Published - 4 years ago ( Updated - 4 years ago )

The mailbox for receiving letters has exploded, and I don’t want all the letters. Use PHP to clear the inbox.
The following is the sample program I copied, with minor adjustments.
<?php
$imap_server="{www.hibox.hinet.net:993/imap/ssl}INBOX";

$mbox = imap_open($imap_server, "mailbox account", "password")
    or die("Can't connect: " .imap_last_error());

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

//mark delete
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);
After execution, it will be cleaned up completely: p

But PHP, PHP does not have imap expansion, I use docker to easily expand php with imap.
I use D-Laravel's Dockerfile, make up the relevant packages, and rebuild the dockerfile.
1. Join the kit:
libc-client-dev libkrb5-dev \
2. Add config 
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
3. Add 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 \
The differences displayed by git version control are attached below.



 

Tags: php

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


phpenv

phpenv database environment

This article describes how to pull out the database service of phpenv to an independent environment. PHPENV can define database services in SERVICE through environment variables. If necessary in the development environment, we can easily restart all services, nginx, fpm and db through commands such as ./start and ./restart. But if it is in online mode, I don't want to restart the website, even the entire DB is restarted. For example, when the php version is updated, the DB does not need to be restarted.

docker,phpenv

Unable to ping host.docker.internal on Linux

You can check with docker version, confirm that the version is Docker v20.10+, you can add extra_hosts as follows:

docker,phpenv

Ran out of Docker IPv4 address pool problem solving

Maybe in the old version of the docker environment, when using Docker compose to start the container, you will encounter the following error: Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network This is actually this It is a symptom of running out of default-address-pools. In some environments, docker-compose will use the private network of Class B by default. The private IP of segment 172 has a range, from 172.16.0.0 to 172.31.255.255. That is to say, when we start a docker-compose Project, it will eat a private section of Class B, which is very heroic.