create a variable that stores the emails in a comma separated list, then use that variable in the UE behavior.
<?php $emails = "";
<?php do { ?>
Teachers email: <?php echo $row_rsTeachersEmail['UserEmail']; ?><br>
<?php $emails .= $row_rsTeachersEmail['UserEmail'].","; ?>
<?php } while ($row_rsTeachersEmail = mysql_fetch_assoc($rsTeachersEmail)); ?>