Fatimah Kubra reported,

Whenever the Messenger of Allah ﷺ entered the mosque, he would send blessings and peace upon Muhammad and say, "My Lord, forgive me my sins and open for me the gates of Your mercy." And when he left, he would send blessings and peace upon Muhammad and say, "My Lord, forgive me my sins and open for me the gates of Your bounty."

Tirmidhi 314

Daif

حدثنا علي بن حجر حدثنا إسمعيل بن إبراهيم عن ليث عن عبد الله بن الحسن عن أمه فاطمة بنت الحسين

عن جدتها فاطمة الكبرى قالت

كان رسول الله ﷺ إذا دخل المسجد صلى على محمد وسلم وقال رب اغفر لي ذنوبي وافتح لي أبواب رحمتك وإذا خرج صلى على محمد وسلم وقال رب اغفر لي ذنوبي وافتح لي أبواب فضلك

الترمذي 314ضعيف
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Prayer
Chapter
What to say when entering the masjid
Numbering
Darussalam 314
Tirmidhi 314