The then-married suspect, surnamed He and in his 30s, met his married girlfriend online in October 2010.
The pair divorced their respective spouses and moved into an apartment together, prosecutors told Shanghai Daily.
The girlfriend asked the man to buy an apartment in Shanghai as a pre-condition to marrying him.
The man had little money after divorcing his ex-wife. And his parents objected to his second marriage and refused to lend him money.
The woman then took a new boyfriend and refused to see him.
Enraged at being betrayed, the man bought firecrackers and steel balls and made a bomb. He then mailed the bomb in a paper box to his girlfriend's home.
The woman's parents received the parcel, and on finding the bomb called the police.
Police said the bomb was so powerful that it could have killed many people.
The man faces up to 10 years in prison.