Many people believe that poetry is not allowed in Islam, no matter what the content is or about what the poem is. The same question was asked from the Darul Iftah of Jamia Binoria town which tried to remove this misconception about poetry.
Mufti Abdul Majid replied that poetry about virtues of Islam and Muslims is not only allowed but is praiseworthy. He said that writing or hearing verses about the glorification of Prophet ? , his sunnah and the Quran is allowed if it is free from polytheism and unislamic things, such as evil thoughts and bidah.
Hassan Bin Sabit was a famous companion of Rasool Allah who wrote poetries praising the prophet and Muhammad (PBUH) appreciated his efforts. His qaseeda which he wrote about last prophet (pbuh) is very famous among Muslims.
So poetry within itself is not haram rather if it contains any unislamic thing then it becomes prohibited.