It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) that the Prophet (peace and blessings be upon him) said: "Whoever has eaten garlic or onion should keep away from us, or keep away from our mosque, and sit in his house."
A platter containing green vegetables was brought to him (peace and blessings be upon him), and he (peace and blessings be upon him) noticed a smell from it. He (peace and blessings be upon him) asked about it and was told which vegetables were in it. He (peace and blessings be upon him) said: "Bring it close to some of the Companions" who were with him (peace and blessings be upon him). When he (peace and blessings be upon him) saw that the man disliked eating it, he said: "Eat, for I converse privately with one with whom you do not converse." That is, (the angels).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النكاح / 13330