Just out of curiosity, what's M about your 325is already?
An M5 V8 will mess your chassis dynamic all up and probably cost three of four times as much as your car did. However, S50/2 (M3) engines have been repeatedly loaded into E30s and the process, while expensive and time consuming, has been well-documented. R3VLimited
has a fairly extensive forum dedicated specifically to this project. I recommend researching what parts are necessary and how much work this is and decide if it's something you want to pursue. Now if you were talking about the S38 engine from an E34 M5 - 3.5/3.8 I6 - that would probably fit more easily than a newer M5's, but they're a lot harder to find and probably still really expensive.
If you get an S38 in there though, you'll be my hero.
Welcome to BimmerWerkz.