Can Thunderbird use a hosts file instead of DNS?

User Help for Mozilla Thunderbird
Post Reply
QF0
Posts: 2
Joined: October 4th, 2022, 1:18 am

Can Thunderbird use a hosts file instead of DNS?

Post by QF0 »

I have a new Postfix mail server on the local network (mail.foo.com, on 192.168.1.150), and I want to test it locally, with no connection to the net.

To do this, I'm using Thunderbird on another machine on the network. I've changed the (Windows) hosts file to point to the new server:

Code: Select all

   
192.168.1.150 mail.foo.com mail
If I then try to send a mail to 'me@mail.foo.com', Thunderbird ignores the local hosts file, and instead does an external DNS lookup for the MX record for foo.com. As it happens, foo.com does have a real MX record pointing somewhere else, and Thunderbird sends the mail to that other server.

So, can I set up Thunderbird to run locally without installing a local DNS server? I could disable the external DNS but that seems like the wrong thing to do, and I don't want the hassle of a local DNS server.

Note that Firefox on the Windows box does correctly use the local hosts file for web connections to 192.168.1.150.
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Can Thunderbird use a hosts file instead of DNS?

Post by tanstaafl »

I've used Thunderbird in the past with hMailServer installed on the same Windows PC, using localhost. I used localhost as the mail server in the account settings rather than modifying a hosts. file. You might try explicitly specifying the ip address (rather than re-configuring the server name in the hosts file) in the account settings as a crude hack if you're the only one using this, and adopt a cleaner solution later on.

https://superuser.com/questions/1125006 ... hosts-file might give you some ideas.

https://superuser.com/questions/1433325 ... hosts-file talks about needing to set network.dns.offline-local to false to get Firefox to use a hosts. file.

https://stackoverflow.com/questions/374 ... he-browser might also be useful.

If you solve this please share what you did.
QF0
Posts: 2
Joined: October 4th, 2022, 1:18 am

Re: Can Thunderbird use a hosts file instead of DNS?

Post by QF0 »

Thanks - the second link, in particular, looks promising. Firefox 'just works' with a Windows host file on any Firefox I've used for years now, but the answer does give a list of config options which might be useful.

However, I've tried pretty much everything, and none of it appears to work on Thunderbird, even after Thunderbird restarts. `network.dns.offline-localhost` doesn't work and appears to be the wrong thing anyway. I've also tried `network.trr.exclude-etc-hosts` (which defaults true anyway), and `network.trr.excluded-domains`. The answers don't point out that 'trr' is the Trusted Recursive Resolver, which is only relevant to DNS over HTTPS. I've tried the `trr` options with and without DNS over HTTPS enabled, but it makes no difference. So, not looking good.
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Can Thunderbird use a hosts file instead of DNS?

Post by tanstaafl »

http://vcloud-lab.com/entries/general/b ... hunderbird describes in detail with screen shots how somebody configured hMailServer to work with Thunderbird. Towards the end it mentions:

"On the Local folders, create a new account select Email. Next skip this and use existing email. It popups Mail Account Setup, type user name, Email address and password. Once it successfully connects to hmail servers and finds user accounts, Press done to add users. I have added 2 DNS A host entries one for imap.vcloud-lab.com and smtp.vcloud-lab.com for hmail hostname and IP. In case your configuration of thunderbird is failing, use manual config to define FQDN (added in the DNS) in the IMAP and SMTP section."

I realize you're using a different mail server but though it might give you some ideas.
Post Reply