I don't know that I can give you THE mechanism, but I think you can probably rationalize how it might form. Sulfur is an interesting reagent as it can serve as both an oxidant and reductant. Aniline readily halogenates in o/p positions. If it also reacted with sulfur, you might get an attack at an ortho position. Elimination could give a thio-aza analog of a quinone. An RSH compound could reduce it to an ortho mercaptoaniline. If you repeat this reaction on the other phenyl ring, you could cyclize the mercaptoaniline onto the thiono carbon, loss of H2S would give a phenothiazine.