Solution 1:

As far as I can see you just want to send mails. In this case you must not set an MX record for the server, as your mail server is not responsible for any domain.

If I understand your problem, you really just want an MTA that relays your mails.

Setting up a full fledged mail server for this purpose is overkill; so first here are a few alternatives: https://unix.stackexchange.com/questions/1449/lightweight-outgoing-smtp-server

If you want to have a real mail server anyway, postfix would be preferable: https://askubuntu.com/questions/457003/setting-up-a-send-only-mail-server

However, your DNS problem is probably independent of this.

Of course it is desirable, that all IPs and hostnames used on your server can be resolved. To achieve this you would need a local nameserver for your local addresses (and names) that forwards any other requests to some other nameserver.

But there might be an easier way: The DNS lookups the mail server performs should depend on the mails sender and receiver domains. You should check, if those are correct and just limit yourself to names, that can be resolved. Maybe you have configured the From-address to point to some locally defined domain?

To debug this, you can try to send mails from the command line first and move on to PHP-mailer as soon as this works.

An example mail from the queue would be helpful to check this.

And could you please post the output of netstat -natp ? Just to see what IP addresses sendmail is bound to.

I know this answer is not complete, but this is as much as I can say at this point.

Solution 2:

As you write, it had to work.

user1316146 is also right: gethostbyaddr is doing reverse ip lookups, which aren't needed for mail sending. The problem isn't here, on my opinion.

I think, you have simply a noisy network or a not really reliable local dns. You had to configure your sendmail to try to get its target address more agressively, and many times.

Or, maybe you should install a local cachingonly bind to make such problems more clear.

Or, maybe you should try a more robust mta, postfix is imho a good way.

Solution 3:

gethostbyaddr is performing reverse DNS, so you need to have PTR records set up for the IP addresses in question. You also needs to have that address range delegated to you for public address.

If you're using 8.8.8.8 as your DNS for the box, you're not going to be able to have PTR records for the 10.0.0.0/8 network.

This lookup usually only occurs for mail being sent IN to the server as the mail server tries to determine the host name of the sender to compare it to the HELO message sent.

By the way, if you're just trying to send mail, the default postfix config works perfectly for that under Ubuntu.