Thanks for the tip Till. It helped me debug the problem.
I checked the isp_isp_web table and found that the optionen_local_mailserver was linked to the main web name, not the co-domains.
If I edit the main web for www.main-domain.com
and remove www from the hostname (leave it blank) and save, then it works - main-domain.com disappears from the local-host-names file. I need to be careful though, because when I edit this web agian, the blank hostname box defaults to www.
So in effect what I'm experiencing is the inability to specify an external mail server for any FQDN other than the main domain for the site (co-domains don't affect local-host-names) and that setting hostname to blank in the ispconfig admin console leads it to default to www upon next save.
Is this intended? Is this fixed in the latest verion? (I haven't upgraded to the version of ISPConfig that came out a few weeks ago yet).