The EE SX671 may not be suitable for your CNC use.
ee-sx47_67_ds_e_13_2_csm483.pdf
The datasheet , page 5 says;
"These Photomicrosensors have an IP50 (conforms to IEC) enclosure
and do not have a water-proof or dust-proof structure. Therefore, do
not use them in applications in which the sensor will be subjected to
splashes from water, oil, or any other liquid. Liquid entering the
Sensor may result in malfunction."