Functionalized porous organic polymers (POPs) with high Brunauer–Emmett–Teller (BET) surface area (SBET) and unique porosity are promising for CO2 capture and Hg2+ removal, although their facile synthesis remains a challenge. Herein, a kind of novel amino-functionalized porphyrin-based POPs was developed based on the Friedel–Craft acylation reaction and Schiff-base reaction, and melamine was adopted as both the rigid cross-linking bridges and the amino-functionalized agent for the construction of the polymers. The resultant polymers exhibited high SBET (587 m2/g) and pore volume (0.46 cm3/g) with abundant amino, imine, and triazine functionalities (42.08 wt %). The CO2 uptake reached 172 mg/g at 273 K and 1.0 bar and the maximum Hg2+ capacity reached 328.1 mg/g. In particular, the characteristic hierarchical micro/mesoporosity of the polymers was beneficial for the kinetic adsorption due to the fast diffusion of Hg2+ in the pore channels. This study offers a facile postfunctionalization strategy to fabricate the functionalized POPs with high surface area and unique hierarchical porosity.