Make absolute link in email

Make absolute link in email

I am creating a function which send an email to user ask for doing something by click on the link . My email send out with a absolute link but host name all ways "localhost". is there is any function to get correct application host name?

we have two zones. one for internal apps and one for public apps.
the hostname is different for each zone. e.g. public url vs internal url
however the service center is shared
how can i enter different hostnames for each zone?