Here's a guide to replacing a purge solenoid valve (04-09 Mazda 3).
Correct part number is LF66-18-74X:
Step 1: Disconnect negative terminal of battery:
Step 2: Disconnect the wire clip from the solenoid valve:
Step 3: Disconnect this fitting near the firewall with the quick-release connector:
Step 4: Disconnect this fitting from the front of the engine:
Step 5: Slide the solenoid valve towards the front of the car to release it from the rubber fitting that holds it in place:
Step 6: Loosen the hose clamp connecting the line from the firewall to the solenoid valve, and remove old valve (which remains connected to the front line).
Step 7: Connect quick-release clamp of new front line to the front of engine (simply snaps on).
Step 8: Reconnect the rear line to the new solenoid valve and tighten hose clamp. Make sure the raised line of plastic on the valve is lined up with the marked line on the rear hose, and slide the solenoid valve back into the rubber fitting:
Step 9: Snap rear line back onto the fitting coming from the firewall.
Step 10: Reconnect wire clip and battery cable:
Step 11: Done!
Step 12: Don't forget to remove this plug from the new front line before trying to connect it :
Credit goes to stsa84
http://www.mazda3forums.com/showthread.php?t=375664