In order to set a message as temporary-failure, we check if it is in pending status first. Otherwise a delivery receipt for failure is set to permanent failure.