by Devin Yang
(This article was automatically translated.)

Published - 3 years ago ( Updated - 3 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


php

Talking about PSRs

The full name of PSR is called "PHP Standards Recommendations" (PHP Standards Recommendations). A proposed specification developed by FIG (PHP Framework Interoperability Group), This group was initiated by some framework developers in php|tek in 2009, from the first 5 to more than 20 now. There are many numbers in the "PHP Standard Recommendations", each number represents a different specification.

php,linux

WebShell Function Introduction and Precautions

I suddenly wanted to introduce what is WebShell, so I found one on the Internet. Its functions are quite good. But I still wanted some features, so I spent three nights making some small optimizations for him. If you haven't heard of WebShell yet, take a look at this video. If you like my optimized version, please give me a like, thank you.

laravel,trait,php

My Browser Trait, webp image file support function detection and whether it is a mobile phone detection

I believe that many people are familiar with PHP trait, because Laravel can be seen everywhere, but I still write it and share it with those who are destined. PHP trait allows two different CLASS to use the same method. It not only reduces the complexity, but also allows the code to be reused. So it should be very convenient to put a Browser series function on Laravel's ViewServiceProvider 😝