<?php $imap = imap_open("{imap.example.org}", "mailadmin", "password");// after some sleepingif (!imap_ping($imap)) { // do some stuff to reconnect}?>