if (empty($email)) {
throw new \Exception("email cannot be empty");
}...
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
<a href="action="./phpmail/index.php""></a>
foreach ($users as $user)и не видно закрытия одного из них