Make sure you have a valid domain in your /etc/hosts (Windows: C:\Windows\System32\drivers\etc\hosts) for 127.0.0.1 along with localhost (space separated or on a new line with the said IP)
Then the valid domain in your php.ini and the changes to your php script should work fine provided your DNS SPF entry is okay for the IP you will be dishing out.