You will need 3 low-power transformers which will transform voltage from 230 (star configuration with neutral in the middle) or 440/380 (between phases) to, say 6Vac. Voltage from each transformer will be rectified and feed to ADC, so you can measure these voltages.
As relay you can use power rating contactor (obviously signal from microcontroller pin has to be amplified to be able to operate this contactor) or for fast swiching - 3 solid state relays (20ms reaction time).
Once a microcontroller (with interna/external analog-to-digital converter(s)) seneses missing phase or lower/higher voltage it will send signal to a "relay" and disconnect power ..