A low cost, solid optical sensor for the rapid detection of low concentrations of Hg2+ in aqueous media was prepared by the monolayer functionalization of mesoporous silica with 5,10,15,20-tetraphenylporphinetetrasulfonic acid (TPPS), anchored by N-trimethoxysilylpropyl-N,N,N-trimethylammonium chloride (TMAC). The detection is based on the color change of TPPS from orange to green as a result of the formation of a charge-transfer complex with Hg2+. The intensity of the charge-transfer band varies linearly with Hg2+ in the concentration range from zero to 2.5 x 10(-7) mol dm(-3). The lower detection limit observed for Hg2+ concentration is 1.75 x 10(-8) mol dm(-3). The material exhibits good chemical and mechanical stability, and did not show any degradation of TPPS for a period of eight months. The sensor was applied for the analysis of various environmental samples. The effects of pH, sample volume, reaction time, amount of material, and the presence of foreign ions on the detection method are discussed.