Following is a basic code to get the last received e-mail using IMAP protocol:

ini_set('display_errors', 1);
error_reporting(E_ALL);

// Debug flag
$mail = imap_open('{mail.example.com:143/debug}', 'test@example.com', 'password');
// or using SSL/TLS $mail = imap_open('{mail.example.com:993/ssl/debug}', 'text@example.com', 'password');

$last_mail = imap_num_msg($mail);

var_dump(imap_headerinfo($mail, $last_mail));
echo imap_body($mail, $last_mail);

imap_close($mail);

One of the funniest and useful things some users tend to do when having a max connection limitation on MySQL is to create several users cyclically or even randomly.

$db_users = array("db_user1","db_user2","db_user3","db_user4","db_user5","db_user7"...);

$db_user = $users [rand(0,5)];

$db_connection = new mysqli($db_host, $db_user, $db_password, $db_name);