you have a DNS problem
coming from outside emails use the internet DNS but going out you have to point to the correct location (local DNS with public DNS on it)
ping does not use DNS so it has no problems connecting
what is the setup? is it a standalone XP or a network?
post the DNS config if you want further help