You could just use a 240 Vac powered 5 V supply, such as a mains driven USB supply that you have kicking around. All your isolation and smoothing is taken care of in the power supply. You may need a load resistor to discharge the output as with no other load it could take some time to decay.
you mean like this ?
If you do use a relay, I would suggest a much smaller load resistor than 10 kΩ. I would use something like 500 Ω to ensure 10 mA flows though the contacts when they close to help keep the contact working. The actual current needed depends on the relay and a minimum current is often quoted for them.
like this ?
regards