Reduce heating in linear power supply
A circuit would help but assuming you are rectifying the mains 240V AC input and smoothing it, you'll get a DC level of about 340Vdc. You are dropping this to 18V with a linear regulator and ultimately the load is 10mA (albeit via a 5V linear regulator).

The power dissipation in the 1st stage regulator, when connected to 240Vac will be the dc volt-drop (340 - 18) x 10mA = 3.22W.

Heating is to do with the power being dissipated and unless you change to a switching regulator of some sort this heat will always be generated.

Temperature, on the other hand can be reduced by using a bigger heat-sink on stage 1 regulator.