Medications used to treat oral ulcers include corticosteroids, anesthetics, and antihistamines. These can be used as gels, mouthwashes, pastes, ointments, etc. Diphenhydramine hydrochloride (DPH) has local anesthetic properties that can help treat the aphthae. One of the drawbacks of the delivery to the transmucosal is the quick turnaround time of the gel, a mucous form that is located on the epithelial film surface. Therefore, it seems that the preparation of a carrier that has the characteristics of adhesive mucus can increase the duration of drug retention on the mucous surface. To solve this problem, mesoporous silica nanoparticles (MSNPs) were synthesized and functionalized with amino and thiol groups and suggested as a system of drug delivery. The properties and structure of MSNPs were investigated by dynamic light scattering (DLS), transmission electron microscopy (TEM), energy-dispersive X-ray spectroscopy (EDS), thermal gravimetric analysis (TGA), Fourier transform infrared spectroscopy (FTIR), and nitrogen adsorption-desorption isotherms (BET). Our outcomes indicated that the average sizes of bare MSNPs (MSN), amino modified MSNPs (MSN-NH2), and thiol modified MSNPs (MSN-SH) were obtained to be 611, 655, and 655 nm respectively and the average pore size of MSN, MSN-NH2, and MSN-SH were about 2.42 nm, 2.42 nm, and 2.44 nm, respectively, according to the BJH (Barrett-Joyner-Halenda) pore size distribution. The release kinetics and release of DPH from mesoporous silica carriers were evaluated. Eventually, the mucoadhesive study and DPH-loaded particles were investigated. Also, the MSN-SH exhibited a high mucoadhesive capacity for buccal mucosa compared with MSN-NH2 and MSN.