How to catch emails on subdomains
Simple: Set an MX record for real.cool.website
and every other subdomain you actually have an A/AAAA or CNAME record for pointing to the cPanel server (and make sure it handles that mail)
For everything else that you want to catch (e.g. misspellings), you can add a wildcard MX entry also pointing to that cPanel server (again making sure it will actually handle this).
You need to add explicit MX records for every name you have DNS records for, as MX wildcards don't match if you have any other records (see this Q&A.
Of course all of this assumes you want your primary mail server to actually handle all mail.
All that said: IMHO you should only really accept mail for real domains you want to have mails - let wrongly spelled and otherwise invalid addresses bounce so that users are aware of their error.
Also note: Any question regarding your cPanel mail server (e.g. how to make it handle subdomains) would be off-topic and are not welcome here.
I'm answering own question (but accepting Sven's answer) as there's more to this, and understanding it may help others.
Given a domain cool.example with an A record for subdomain really.cool.example, and an MX record for cool.example what will happen is this:
- emails to [email protected] bounce back instantly
- emails to [email protected] "seem" to disappear with no bounce back
But what is actually happening is that emails sent to [email protected] will eventually result in a "delivery failed" message, but only after a few days of trying, which, when testing, may give the impression they end up nowhere.
This because the subdomain idontexist.cool.example cannot be found at all so results in an immediate bounce back, whereas really.cool.example is found (because of the A record) but cannot handle mail (because there's no MX record) and so the mail service keeps trying for a few days.
The solution, as @Sven and @Michael Hampton point out, is to create an MX record for any subdomain you wish to capture mail for (being mindful that MX wildcards don't match if you have any other records, which is very likely if your site is entirely on a subdomain, so you need to create explicit MX records).
@Sven also says:
you should only really accept mail for real domains you want to have mails - let wrongly spelled and otherwise invalid addresses bounce so that users are aware of their error.
I agree with that, but the problem is how long the user has to wait to be informed that they made an error - which in the case of an email sent to a subdomain for which there is an A/CNAME record but no MX record could be a few days, which is probably not acceptable.
To get round this you can:
- Create a NULL MX record for the subdomain (preference of 0 and point to ".") which will cause an immediate bounce back, but not all DNS providers or their interfaces* let you do this.
- Create an MX record pointing to a mail server configured to send an automated reply, just so the user isn't left hanging for a few days.
*e.g. at time of writing Linode's web interface does not allow this, yet it seems possible to achieve this via Linode's CLI tool.