[Machine] The Messenger of Allah ﷺ said, "When one of you enters the mosque, he should greet (say salaam) and say, 'O Allah, open the doors of Your mercy for me.' And when he exits, he should say, 'O Allah, I ask You for Your favor (grace).'"
Narrated Abu 'Abdur-Rahman As-Sulami: Abu Mansur Muhammad bin Al-Qasim Al-'Ataki informed us, narrating from Al-Hasan bin 'Abdus-Samad Al-Quhundi, who narrated from Yahya bin Yahya, who informed us that Sulaiman bin Bilal narrated to us, and he mentioned it in a similar manner except that he did not mention the part about saying salaam.
قَالَ رَسُولُ اللهِ ﷺ إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ فَلْيُسَلِّمْ وَلْيَقُلِ اللهُمَّ افْتَحْ لِي أَبْوَابَ رَحْمَتِكَ وَإِذَا خَرَجَ فَلْيَقُلِ اللهُمَّ إِنِّي أَسْأَلُكَ مِنْ فَضْلِكَ 4318 وَثنا أَبُو عَبْدِ الرَّحْمَنِ السُّلَمِيُّ أنبأ أَبُو مَنْصُورٍ مُحَمَّدُ بْنُ الْقَاسِمِ يَعْنِي الْعَتَكِيَّ ثنا الْحَسَنُ بْنُ عَبْدِ الصَّمَدِ الْقُهُنْدَزِيُّ ثنا يَحْيَى بْنُ يَحْيَى أنبأ سُلَيْمَانُ بْنُ بِلَالٍ ثنا رَبِيعَةُ بْنُ أَبِي عَبْدِ الرَّحْمَنِ فَذَكَرَهُ بِنَحْوِهِ إِلَّا أَنَّهُ لَمْ يَقُلْ فَلْيُسَلِّمْ