THE PROBLEM
I wanted to walk through the play-by-play because this was not a normal troubleshooting episode and I feel someone else is going to discover this post and be glad to save the time I lost. Spoiler alert: The problem was old cpanel records! But it’s worth spending the time going through this post in detail…
I also wanted to send a shout-out to the Stalwart team! Fantastic project. Keep up the good work. The problems in this post have nothing whatsoever to do with Stalwart and in fact Stalwart helped me solve my problem with it’s nice clean and simple logs.
For the play-by-play, I’ve made these placeholders:
problemdomain.com is the domain that was having endless problems in StalwartMyBadhostname.com is an active domain with active email addresses that I own on a shared cpanel account
PROBLEM PLAY-BY-PLAY
- Years ago, I had problemdomain.com hosted on an old cpanel shared host – the same place
MyBadhostname.comis currently hosted/active - Until now,
problemdomain.comwas there, but not being used – completely inactive and just sitting there because I was too lazy to delete it from cpanel - My domain registrar was somewhere else – totally separate company from my host where my Stalwart VPS is and from the old cpanel host – just to show there is no connection there either.
- I added
problemdomain.comto Stalwart as a new Domain, and created certs, just like all the other successful domains. - I pointed the NS records from my domain registrar of
problemdomain.comto CloudFlare, like I always do. - I added the account
email@problemdomain.comas a new email Account in Stalwart, just like I did for the other successful email accounts - I connected the new email account
email@problemdomain.comto my Stalwart server successfully with Thunderbird email client - I sent many test emails to various hostnames from
email@problemdomain.comAccount and they were successful – I got a 10/10 score on email testing, in fact. - I tried sending to
email@problemdomain.comfrom various email addresses and hostnames and they all succeeded. - However when I tried to send an email from
email@problemdomain.comto one very specificemail@MyBadhostname.comemail address – it failed with the following error message:
<email@MyBadhostname.com> (host 'MyBadhostname.com' rejected command 'RCPT TO:<email@MyBadhostname.com>' with code 550 (0.0.0) 'Verification failed for <email@problemdomain.com>No Such User HereSender verify failed')
- In the Stalwart logs, I was getting: blank sender info in brackets like this
<>where an email should have been a full email address. This also looked suspicious compared to all the other logs - I thankfully own and control multiple email accounts at
MyBadhostname.comand when I tried sending from all of them toemail@problemdomain.comthey all failed as well with the same error - I tried every tool I could think of for diagnostics including telnet and swaks and online tools like mxtoolbox – all suggested that both sides were ok!
- I could confirm for sure that literally ONLY these two domains could not email each other.
Finally… an idea dawned on me.
THE SOLUTION
- Finally, in an act of curiousity, I decided to delete completely
problemdomain.comas a domain from the shared cpanel host and BOOM! – All the emails started flowing!
CONCLUDING WORDS
The problem was entirely internal at the cpanel hosting environment where it still had the residual DNS records (in itself) and must have been confused and still thought that the mail and its records should also be there and was therefore messing up. As if both servers thought each other was the mail server.
Conclusion: Be aware that old domain and DNS records left around the internet… are bad. Delete when you know you’re setting up something like an email server or new mail service – especially new email service since it’s so finicky…
Hope this helps at least someone diagnose the impossible….