To obtain the URL of the server you can use GetURL(), but this will only work if you're making a request to the application, since GetURL action is based on the HTTPRequestHandler. If that is the case - say, you send the email on the click of a button - then don't forget to parse the server from what GetURL() returns.
On the other hand, as is the case of the daily digest which is usually initiated by a timer, the URL returned by the HTTP request will always be 127.0.0.1. You have 2 workarounds:
Hope that helps,
In version 4.x, the best way specify the domainname (to pass to richmail, I assume) is to place it in a Site Property and define it once for your application. It is how we handle it for the network forum email notifications.
Are you sure you were using GetURL action from HTTPRequestHandler? Maybe it's another version.
Here's a sample eSpace that returns the output from a button submit and from a timer - check out the differences.