In a nutshell: Avoid a collsion, and you won't take damage.
But here some explanations:
If there is no collision on your screen, you take no damage. If there is one, you will take it. How much damage you take is depending on what parts of your plane get into contact with the enemy.
But how comes that my enemy does not take damage?Due to lag, what your opponent sees on his screen is never exact the same what you are seeing. So it is possible (and happens quite often) that there is a collision on your screen and none on his (maybe missing you only by a few feet). And vice versa.
If you see only see "XXX has collided with you", there was a collsion on his screen only - only he takes damage
(If you are taking damage though, you just have been shot)
If you only see "You have collided", the collision was on your end only.
If you see both messages, a collision has happened on both ends. Both take damage (though the actual amount can differ vastly)
There is a chance you may experience something like a "deliberate ram": For example a very fast enemy buzzing past you while you did fly straight & level (maybe AFK). But this is quite rare, and actually extremely difficult to induce deliberately by your enemy, for he has no clue how you both are positioned on your Front End.
For a more indepth discussion of lag, go to
http://trainers.hitechcreations.com/ and read "How lag affects Aces High"