note 22517 deleted from function.imap-uid by googleguy

From: Date: Tue, 22 Oct 2013 09:02:57 +0000
Subject: note 22517 deleted from function.imap-uid by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196854@lists.php.net to get a copy of this message
Note Submitter: ---- For those using a POP3 mailbox, this function, as noted, does not work. One way around this is to use direct FTP communication with the mail server. For example, the following function takes a mailbox/password and message sequence number, and from this returns the message UID. function fetch_UID($account, $password, $message_number) { $retval = 0; $fp = fsockopen($POPMAILSERVER, 110); if ($fp > 0) { $buf = fgets($fp, 1024); fputs($fp, "USER $account\r\n"); $buf = fgets($fp, 1024); fputs($fp, "PASS $password\r\n"); $buf = fgets($fp, 1024); fputs($fp, "UIDL $message_number\r\n"); $retval=fgets($fp, 1024); fputs($fp, "QUIT\r\n"); $buf = fgets($fp,1024); fclose($fp); } return substr($retval,6,30); } Note: 110 is the TCP port commonly associated with a POP3 mailbox. Also the substr() function is used to trim the +OK and the message number from the beginning of the server's response. I'm sure there are other (better) ways to do this. But after a fruitless search of the internet, this is what I came up with, and it seems to work for me.

« previous php.notes (#196854) next »