If you have ffmpeg installed, you can use it to play a sound of almost any filetype:
ffplay -nodisp /path/to/sound/file
Unfortunately that will spawn a window in most versions of ffmpeg included with Linux distributions, though it has been fixed in the latest version. If that's undesirable, you can also use the aplay command, but that can only play WAV, AU and other raw audio formats:
aplay /path/to/sound.wav
If you don't want to have to type that every time, you can write a little script to do it for you. Just drop a file like this to somewhere like ~/bin/fetchsound and make it excuatable (chmod +x ~/bin/fetchsound):
#!/bin/bash
fetchmail [..]
if [ $? -le 1 ]; then
ffplay -nodisp /path/to/sounds/success.ogg
else
ffplay -nodisp /path/to/sounds/failure.ogg
fi
You could also just have it play a sound when you have new mail, because fetchmail returns a 0 exit code when it downloads new mail and 1 when it doesn't. (All other status codes indicate a failure.)
#!/bin/bash
fetchmail [..]
if [ $? -eq 0 ]; then
ffplay -nodisp /path/to/sounds/newmail.ogg
elif [ $? -gt 1 ]; then
ffplay -nodisp /path/to/sounds/failure.ogg
fi