Unfortunately in shared hosting, you are not likely to have access to /etc/hosts
file to specify your own DNS resolution overrides. Just refer to the resource using it's IP address and you should not have any need to do DNS resolution at all.
If the resource changes IP address, then you could potentially create a separate process to determine DNS resolution for the resource and cache the IP locally, then again use that IP address in your imap_open()
call.