The setup was this: a domain example.com, registered at Domaindiscount24 (dd24.net) as the DNS hoster, and set up there so that there was an “IN A” record pointing to the Hostgator server’s IP address, and a “IN MX” record containing “10 example.com” (with 10 being the priority). On the Hostgator server, the example.com domain was registered for webspace (and this worked), and a mail forwarder to another domain (also hosted on Hostgator) was set up, but no e-mail accounts for example.com.
The exact same style of setup worked for e-mail for another domain, also at DD24 and Hostgator, for which webspace and a mail account was set up.
However, in this case, the mail forwarder for the example.com address did not work: mails did not get forwarded, except if they were sent from another domain that was hosted on the same Hostgator server. The mails also did not appear in the customer-wide spam folder, and no error message was sent back to the sender (which effectually means that the mail was lost). It seems also that sometimes, the forwarding is successful, for whatever reason.
The error might be: before forwarding, according to the DD24 entry, the mailserver of example.com has to be contacted. But there might be a bug on Hostgator’s server configuration that only creates such a server when a mail account (not a mail forwarder) for this domain is created. The strange thing is however, that the mail senders do not receive errors back when sending to example.com addresses. Which might be because the Hostgator server accepts such mails in a kind of catchall address, but cannot distribute them to the different customers hosted on that server as it does not know what domain belongs to what customer.
The workaround for this error (tested successfully) is to set up e-mail forwarding (at best, with a wildcard) directly at the DNS hoster (here, DD24). This change takes effect on DD24 in a few minutes, but because of the DNS cache times it propagates for use in normal mail software only in 4-7 days. You can see that by the difference in the output of the following commands:
dig example.com MX dig @ns1.domaindiscount24.net example.com MX
If both contain something lilke “example.com. 28800 IN MX 10 mailfw3.dd24.net.” (and a second line like it), the change is complete. This happened in the current case some 4-6 hours after doing the change in the DD24 admin area.
This however leaves one problem untreated: when sending a message to example.com from a domain that is also hosted on the exact same Hostgator server as example.com, the SMTP agent on that server that has to send this message seems to think that it is also the MX server for example.com, does not find the specified target mailbox, and subsequently returns an error message to the sender: “Mail delivery failed: returning message to sender. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: email@example.com No Such User Here.” This is again a DNS routing bug on the Hostgator servers, because a MX record must be used if it is present, as it is here, according to RFC 5321 sec. 5 (http://en.wikipedia.org/wiki/MX_record#History_of_fallback_to_A). The workaround is to go to the Hostgator e-mail administration tool and re-enable a mail forwarder *@example.com to a target mail address, which will take effect only for mails dispatched by the SMTP agent on that server.
This last step of adding an e-mail domain forwarder (from *@example.com to a target address) has the added advantage that using an example.com mail address as the From address becomes now possible, whereas else, the SMTP client on the Hostgator server would reject sending such mails.