I used to be a raver, and did E perhaps a dozen or so times. (Not as many as some, but enough for me.) While it’s a complicated story, suffice to say the odds are decent that it damages the serotonergic system in humans at recreational dosages. Large doses and stacking make it worse. Low doses (like, maybe 1 pill) might be harmless, but nobody knows for sure because none of the research is unbiased (on both sides). While it’s certainly healthier to avoid E, if you’re going to use it, the best way to stave off damage is to take an SSRI (Prozac, Paxil, Zoloft, etc - Prozac is best) after you peak. The SSRI has a higher binding affinity for the serotonin receptor, and will push out the MDMA. The last time I researched the matter, the thinking was that damage came from too much breakdown/diffusion of serotonin in the synapse, leading to the uptake of dopamine by the serotonin uptake system, which converts the dopamine into hydrogen peroxide and essentially bleaches the inside of the cell. Prozac prevents dopamine from being absorbed by the wrong pathway. Another suggestion is to take beforehand some L-tryptophan or 5-HTP, serotonin precursors, so that you have more serotonin than usual, and are less likely to “run out” in the brain. Finally, to prevent hydrogen peroxide from doing damage, antioxidants like vitamins C and E are good, although they’re no substitution for an SSRI.
A more acute health risk is that of overheating while dancing in a crowded area all night. Take breaks and drink fluids, preferably sports drinks. Most deaths from E are actually from heat stroke.
Lastly, the effect that going to prison has is really inconducive to mental well-being. :D