Mail app bug? Email server rejects connection (401 4.5.2 <[0.0.0.1]> HELO command rejected: invalid IP address) when iPhone tries to send email
I'm trying to figure out what's happening. One device, an iPhone running 'latest' iOS (presumably 12.1.4), reports it's unable to reply to a valid email address. The iPhone Mail error is pretty unhelpful:
I happen to be the administrator of the server which this device sends emails through. Until tonight, this device has worked fine - nothing else has changed on the server or the email account.
I checked the mail logs for the device's attempts to send emails which resulted in failure and they reveal a very weird behaviour. Via either 4G or WiFi, and also after a reboot, the device is HELOing with an (RFC invalid) IP of 0.0.0.1:
On my own iPhone 5S running 12.1.2, emails through the same server work fine, the device HELOd with a valid IP (its NAT IP at the time of the test) and the email sent fine. I upgraded it to 12.1.4 and it still works OK, so this problem seems isolated to a single device but it doesn't relate to which network (WiFi/4G) it's using. It's not using IPv6 in either case.
Is this a network stack or a Mail bug? Anybody seen this on their device? At the moment I'm stumped as to the root cause and solution.