Hi, and thanks for your medical question on eHealth forum!
Anal sex and the fact that he did not ejaculate inside you makes you safe from pregnancy. Also normally if you have a 28 day cycle and have periods for 4-5 days only, then sex during periods cannot make you pregnant. Hope this helps. Take care!