[#7062] set first email to primary if none; unset primary when its deleted