make mail notification helper function more generic