Whenever the Messenger of Allah ﷺ entered the mosque, he would invoke blessings and peace upon Muhammad and say, "Allah, forgive me my sins and open for me the gates of Your mercy." When he left, he would invoke blessings and peace upon Muhammad and then say, "Allah, forgive me my sins and open for me the gates of Your bounty."Ismail said, "I met Abdullah bin Hasan and asked him about this hadith, and he said, 'When he entered, he would say, My Lord, open for me the gate of Your mercy, and when he left, he would say, My Lord, open for me the gate of Your bounty.'"
حدثنا إسماعيل بن إبراهيم قال حدثنا ليث يعني ابن أبي سليم عن عبد الله بن حسن عن أمه فاطمة ابنة حسين
كان رسول الله ﷺ إذا دخل المسجد صلى على محمد وسلم وقال اللهم اغفر لي ذنوبي وافتح لي أبواب رحمتك وإذا خرج صلى على محمد وسلم ثم قال اللهم اغفر لي ذنوبي وافتح لي أبواب فضلك قال إسماعيل فلقيت عبد الله بن حسن فسألته عن هذا الحديث فقال كان إذا دخل قال رب افتح لي باب رحمتك وإذا خرج قال رب افتح لي باب فضلك
Its isnad is hasan, on account of Layth bin Abu Salim, while Fatimah bint Husayn is among the trustworthy, excellent, well-known narrators. The hadith was narrated by Tirmidhi 2/177, no. 314, and he said, "It is not connected in my view, because Fatimah bint Husayn did not reach [the time of] Fatimah the elder," and that is indeed so. But such a report is accepted in a case like this.