If you need to use the uid instead of msgno use
imap_clearflag_full($stream, implode(',', $flags), '\\DELETED', ST_UID);(PHP 4, PHP 5, PHP 7, PHP 8)
imap_undelete — Nimmt eine bereits gesetzte Löschmarkierung einer Nachricht zurück
Entfernt das "gelöscht"-Flag der angegebenen Nachricht. Das Flag wird von den Funktionen imap_delete() oder imap_mail_move() gesetzt.
imapEine IMAP\Connection-Instanz.
message_nums
       Ein String, der eine oder mehrere Nachrichten im IMAP4-üblichen
       Sequenzformat darstellt ("n",
       "n:m" oder eine Kombination daraus, durch Kommas
       getrennt).
      
flags
   Gibt immer true zurück.
  
| Version | Beschreibung | 
|---|---|
| 8.1.0 | Der Parameter imaperwartet nun eine
  IMAP\Connection-Instanz; vorher wurde eine gültigeimap-Ressource erwartet. | 
If you need to use the uid instead of msgno use
imap_clearflag_full($stream, implode(',', $flags), '\\DELETED', ST_UID);The imap_delete function allows the option to use a UID for the message number but the imap_undelete function does not.