How can I tell if I have a hemorrhoid or a boil? It painful and bleeding, at the very edge of rectum. Can anal sex cause either? How do I treat it?

See a doctor. abscess is rare unless you had one before or you have disease that can cause fistula most likely it is either a hemorrhoid,or anal fissure that can cause severe pain and rectal bleeding and could get aggravated with anal sex go and see a doctor for proper evaluation and treatment.