Just as any action related to cybercrimes, it is not legal. In some countries, even impersonating someone (during the email spoofing) may lead to punishment. But for most places, it is safe to disguise your emails as ones from delivery service - when you are doing it for a joke. Nonetheless, any harm related to these messages, even if it was not intentional, will likely lead to a lawsuit.