Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1056625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:44:29+00:00 2026-05-16T17:44:29+00:00

I am using php imap functions to parse the message from webmail. I can

  • 0

I am using php imap functions to parse the message from webmail. I can fetch messages one by one and save them in DB. After saving, I want to delete the inbox message. imap_delete function is not working here. My code is like that:

$connection = pop3_login($host,$port,$user,$pass,$folder="INBOX",$ssl=false);//connect
$stat = pop3_list($connection);//list messages

foreach($stat as $line) {
  //save in db codes...
  imap_delete($connection, $line['msgno']);//flag as delete
}

imap_close($connection, CL_EXPUNGE);

I also tested – imap_expunge($connection);
But it is not working. The messages are not deleted. Please help me out…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:44:30+00:00Added an answer on May 16, 2026 at 5:44 pm

    You are mixing POP and IMAP.

    That is not going to work. You need to open the connection with IMAP. See this example:

    <?php
    
    $mbox = imap_open("{imap.example.org}INBOX", "username", "password")
        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 = 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);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP's IMAP functions to retrieve messages from a POP3 mailbox & was
I'm trying to parse HTML data in an email using PHP's IMAP functions. When
I'm using PHP's built in IMAP functions to build a bare-bones webmail client (will
I'm using the imap PHP functions fetchstructure or imap_body depending on message type to
PHP provides very useful functions to fetch emails from a POP3 account, in my
Using PHP 5.3.8. I'm attempting to implement two functions, save($adoption) which serializes an Adoption
I am retriving my mails using php imap function. I am retriving all messages
I am developing a simple webmail client for IMAP-based email services using PHP's IMAP
I am using IMAP to fetch mails from an inbox, Now I want to
Using PHP I'm trying to download/save the following image: http://www.bobshop.nl/catalog/product_image.php?size=detail&id=42428 When you load this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.