It is narrated from Sayyiduna Jabir (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) forbade (the eating of) onions and garlic at the time of Khaybar. However, some people ate them and then came to the mosque. The Prophet (peace and blessings be upon him) said to them: "Did I not forbid you from eating these two foul-smelling trees?" The people said, "Yes, O Messenger of Allah! But we were overcome by hunger." Upon this, the Prophet (peace and blessings be upon him) said: "Whoever eats from this foul-smelling tree should not come near our mosque, for that which causes harm to humans also causes harm to the angels."
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 15159