Healthy sleep is vital to maintaining the body's homeostasis. With the development of modern society, sleep disorder has gradually become one of the most epidemic health problems worldwide. Shumian capsule (SMC), a kind of traditional Chinese medicine (TCM) commonly used for insomnia, exhibits antidepressant and sedative effects in clinical practice. However, the underlying mechanisms have not been fully clarified. With the aid of a network pharmacology approach and function enrichment analysis, we identified the involvement of melatonin receptors in the antidepressant and sedative effects of SMC. In sleep-deprived mice, SMC treatment significantly alleviated insomnia and relevant mental alterations by improving both sleep latency and sleep duration. However, ramelteon, a selective melatonin receptor agonist that has been approved for the treatment of insomnia, only improved sleep latency. Additionally, SMC exhibited comparable effects on mental alterations with ramelteon as determined by an open-field test (OFT) and forced swimming test (FST). Mechanistically, we revealed that the melatonin receptor MT1 and MT2 signaling pathways involved the therapeutic effects of SMC. In addition to the single effect of traditional melatonin receptor agonists on treating sleep onset insomnia, SMC had therapeutic potential for various sleep disorders, such as sleep onset insomnia and sleep maintenance insomnia. Convergingly, our findings provide theoretical support for the clinical application of SMC.