It only works if I use the name of openfire machine, but when I use openfire domain in server it doesn’t work. (Users cannot know the name of the machine if they want to create account so it is a problem, they know just the domain (mydomain.com) ) .
Then you should make sure, that the domain can be resolved to the machine name in your network. I have no idea how, because I am no network admin, but if it helps: XMPP uses DNS RR records to resolve the actual server address from the domain name.