SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Deleting mail from a pop3 server!!

    When you have a socket connection to a pop3 server is there a way to delete every message currently sitting on the server for the account???

    Thnx
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  2. #2
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Deleting mail from a pop3 server!!

    Originally posted by mad-onion
    When you have a socket connection to a pop3 server is there a way to delete every message currently sitting on the server for the account???

    Thnx

    I wrote an email removal program for pop3 with PHP.. I don't think there's a single command to remove all messages (but of course, I never did read through the whole POP RFC either :)

    I ended up just opening the socket, login, the pop server will respond with the number of messages you have. The loop from 1 to that number and deleting them off.

  3. #3
    We are vigilant icehousedesigns's Avatar
    Join Date
    Dec 2000
    Location
    Io
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No there isn't..you have to do it one by one...unless of course you have SU access then you can remove the whole spool

  4. #4
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for both of you...would either of you care to share some code as i just dont seem to have this right!
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  5. #5
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's just a snippet.. I'm not sure how outdated this thing is.. perhaps I should go through it sometime and try to make it more efficient

    Remember, do NOT copy and paste this code. It's just showing you how I communicated with the mail server.. for more information on that, you should view RFC 1939

    PHP Code:

    /* Just a function I wrote that will be used.. */
    function gettok($string,$n,$c) {

            
    $tokenString explode(chr($c),$string);
            return 
    $tokenString[$n-1];

    }

    /* Making the connection to the mail server */
    $popServer "pop.blahblah.com";    //POP server name
    $popPort 110;                 //POP server port

    $mailSock fsockopen($popServer,$popPort,&$error_number,&$error_description);

    if (!
    $mailSock) echo $error_number.": ".$error_description;
    else {

            
    /* Logging into the mail server. Assuming that $username and
                $password are the username and password */

            
    fgets($mailSock,512)."<br>";

            
    fputs($mailSock,"user ".$username."\n");
            
    fgets($mailSock,512)."<br>";

            
    fputs($mailSock,"pass ".$password."\n");
            
    $mailStat fgets($mailSock,512);
            
    $mailNumMsg gettok($mailStat,4,32);

            if (
    $mailNumMsg == "") {
                    echo 
    $font.$mailStat;
                    
    fclose($mailSock);
                    exit;
            }

            
    /* Deletion */
            
    for ($i 1$i <= $mailNumMsg$i++) {
                    elseif (
    $type == "all") {
                            
    $j++;
                            
    fputs($mailSock,"dele ".$i."\n");
                            
    fgets($mailSock,512);
                    }
            }
            echo 
    $font."Expunged ".$j." messages.<br>\n";
            
    fputs($mailSock,"QUIT\n");
            
    fclose($mailSock);
            exit;



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •