The recommended distance between the emitter and the phototransistor is 10 mm for this configuration. The circuit is suggested by the Texas Instruments opto-electronics manual. The relay must be according to the circuit supply.