Has your car ever had headgaskets replaced or overheated?
Now I have a fried that has a wrecked 2004 forester with really low miles. He said that if I pull the motor I can have it. So will a 04 Forester 2.5 Auto motor work?
Nice hit (yes a pun)! Get that motor now!!
If yours has EGR make sure this one has EGR as well.
If yours doesn't have EGR then it'll work either way.
I'm unsure if there are differences but it's an easy check.
Some intakes differ, just swap your intake hoses/set up onto the new motor. Or the entire intake manifold if you have to, they are intechangeable and bolt right up.
Some 00-04 EJ25's have differing trigger points on the cam and crank sprockets. Simply swap the sprockets and that's it, motors are identical in every other way. Very easy swap. I haven't narrowed down which motors this applies to and why some are different but it's definitely a 00-04 thing, somewhere in that range.
Nearing 10 years old I'd be installing a new timing belt, tensioner, and pulleys while it's out (ebay kits are only like $160 - $180 for the above). If you do that, just swap the cam and crank sprockets to be sure.
In the end you can definitely swap your heads and intake onto that 04 block for sure. So either way it will work for you and is a great fit.
A used EJ25 with known history (low mileage, probably never overheated) is hitting the lottery in motor world, particularly with the EJ25's propensity towards headgasket issues and overheating.
With the motor out you could even entertain the idea of installing new headgaskets now, the SOHC EJ25's are actually fairly simple.
A more general response to your question:
99 Forester/Impreza RS and all 2000-2004 EJ25's should work.
99+ 2.2 liters work as well if you get the exhaust manifold with them.
Now that I've helped you, are your old heads available?