Freebsd Email Notification

To get notification about not read email on local system, create file in /usr/local/etc/profile with following content:

unread_count=$(echo q | mailx -N | head -n2 | tail -n1 | cut -f4 -d" ")
if [ -n "$unread_count" ] && [ "$unread_count" -gt 0 ]; then
    echo -e "\n\tYou have $unread_count unread mail message(s).\n"
fi