The two words are interchangeable for the most part, but there is a small difference (which few people would notice anyway).
'Mostly' is used more for things which are quantifiable.
"The crowd was mostly young people."
'Mainly' is used for more abstract concepts.
"His speech dealt mainly with economics."
"His duties consist mainly of supervising the different departments."
However, you could interchange these words and few people would notice and nobody would fault you for it.