Sol, I finally had success. I've stripped out the relevant code from my script and pasted it here - it's notated somewhat. Now, I've not tested this by itself, but you should be able to plug in your own vars and then save the $image to a place on your own server to test it. Good Luck!
<?
$pop_server = "yourdomain.com";
$port = "110";
$username = "username";
$password = "password";
$mbox = @imap_open("{".$pop_server.":".$port."/pop3}INBOX", $username, $password);
$struct = imap_fetchstructure($mbox, "2", FT_UID); //the second parameter is the message ID ie. "2" is the second message.
$attachment = count($struct->parts);
if($attachment){
print("Attachment: ");
for($a = 1; $a < $attachment;$a++){
$inlineitems = $struct->parts;
$dpara = $inlineitems[$a]->dparameters;
$filename = $dpara[0]->value;
echo $filename."<br><br>";
//Get the image:
$image = trim(@imap_fetchbody($mbox, "2", "2")); // the second parameter is the message number and the third is the attachment part -in this case the .jpg.
$image = preg_replace("|\n\r|", "", $image); //take the carriage returns and new lines out--Sol, this is the item I wrestled with, do this then the base64_decode() function works fine
$image = base64_decode($image); //decode the binary$fd = fopen($dir,"w");
if(!$fd) echo "<br><br>Cannot upload file to "." /filess/".$filename;
else {
fputs($fd, $image);
fclose($fd);
echo "<br><br>File uploaded to <a href='http://www.yourdomain.com/files/".$filename."'>Download Image</a>";
}
?>