It uses the one that's indicated in the php.ini file.
You can do it with IP or hostname, the default port is 25.
Make sure it relays on the web server's location.
If you are using PHP as an Apache Module, don't forget to restart the daemon.
Good Luck.