Prayer is composed of invocation, Qur’an recital, bowing, prostration, standing and sitting.
He whose heart is veiled by inattention is veiled from Allah, not apprehending or contemplating Him, but oblivious of whom he is speaking to, merely moving moving his tongue out of habit.
How far this is from what is meant by prayer, which has been established to polish the heart, renew one’s remembrance of Allah Mighty and Majestic, and to deepen the ties of faith in Him.
As for bowing and prostrating, the point of them is certainly veneration, for if not, nothing remains but movements of the spine and head.
Every prayer performed without presence of heart is closer to deserving punishment (Hasan al-Basri)
Whoever knows who is on his right or left intentionally while at prayer has no prayer (Mu’adh ibn Jabal)
And the Prophet (Allah bless him and grant him peace) said,
Truly, a servant performs the prayer without a sixth of it being recorded for him or a tenth, but only as much as he comprehends.
Had these words come from anyone else, they would have been adopted as “a school of thought”. How then can we not go by them? ‘Abd al-Wahid ibn Zayd said, “Scholars concur that none of a servant’s prayer counts for him except what he comprehends”, a position he considered established by scholarly consensus (ijma’).
But while the truth lies in returning to the evidence of primary texts and hadiths, and the evidence is compelling that presence of mind is a condition for prayer, the context in which formal legal opinion can define outward moral responsibility is limited by the extent of people’s shortcomings, and it is not possible to require them to have full presence of mind throughout the prayer, which hardly anyone can do except for very few.
Source: Ihya’ ‘ulum al-din (1.143-44)