Mail Failing to Send SMTP Password

emailmail.apppassword

Very frustrating issue started yesterday with Mail suddenly deciding that it's not going to send my SMTP password to my outgoing mail server. Nothing else has changed, it just suddenly isn't working. I operate the mail server myself, so I know that nothing has changed on the server end either, and that the settings are all exactly right; I have in fact been sending messages just fine for the past few months.

I'm not sure if it's related, but under my SMTP server list the "Automatically detect and maintain account settings" checkbox is enabled and greyed out, making it impossible to disable it. If I manually edit Accounts.plist to set ConfigureDynamically to false then Mail just overwrites it true again.

I really have no idea what's happening, as Mail seems to be simply failing to send my SMTP password, instead sending an asterisk (abort). Here's a sample of the SMTP connection log immediately after setting a new SMTP password and trying to send:

INITIATING CONNECTION Feb 09 08:31:03.579 host:mail.example.org -- port:587 -- socket:0x0 -- thread:0x7ff7fe690170

CONNECTED Feb 09 08:31:03.703 [kCFStreamSocketSecurityLevelNone] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170

READ Feb 09 08:31:03.881 [kCFStreamSocketSecurityLevelNone] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
220 mail.example.org ESMTP

WROTE Feb 09 08:31:03.927 [kCFStreamSocketSecurityLevelNone] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
EHLO [192.168.0.14]

READ Feb 09 08:31:04.033 [kCFStreamSocketSecurityLevelNone] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
250-mail.example.org
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

WROTE Feb 09 08:31:04.033 [kCFStreamSocketSecurityLevelNone] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
STARTTLS

READ Feb 09 08:31:04.160 [kCFStreamSocketSecurityLevelNone] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
220 2.0.0 Ready to start TLS

WROTE Feb 09 08:31:04.263 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
EHLO [192.168.0.14]

READ Feb 09 08:31:04.504 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
250-mail.example.org
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

WROTE Feb 09 08:31:04.569 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
AUTH LOGIN

READ Feb 09 08:31:04.670 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
334 VXNlcm5hbWU6

WROTE Feb 09 08:31:04.670 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
dXNlcm5hbWVAZXhhbXBsZS5vcmc=

READ Feb 09 08:31:04.768 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
334 UGFzc3dvcmQ6

WROTE Feb 09 08:31:04.786 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
*

READ Feb 09 08:31:04.887 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
501 5.7.0 Authentication aborted

WROTE Feb 09 08:31:04.887 [kCFStreamSocketSecurityLevelTLSv1_0] -- host:mail.example.org -- port:587 -- socket:0x7ff7fdf17f20 -- thread:0x7ff7fe690170
QUIT

(I replaced the domain with example.org)

As you can Mail sends an e-mail address when asked, but when asked to send a password it sends *, which causes the mail server to abort authentication, i.e- it's not even sending a password.

Why isn't Mail sending my password, and what can I do to fix it? I've already checked under Keychain Access and the correct password is definitely being saved for my SMTP server, so I have no idea what's going on.

Just wanted to add as well, but I've tried manually connecting to the SMTP server using openssl s_client -starttls smtp -connect mail.example.org:587 and manually entering commands, including the AUTH LOGIN steps with my base64 encoded password, and authentication is successful, the fault appears to be only with Mail, so the status quo for OS X Mail in my experience 😉

Best Answer

So it seems I may have just stumbled upon the cause myself; in addition to my active e-mail accounts, I also had two disabled IMAP accounts (no SMTP details) that I've been migrating from recently. It turns out that while these were listed in Mail they were not listed under Internet Accounts, contrary to what Mail would say when I tried to remove them.

Closing Mail, opening ~/Library/Mail/V2/MailData/Accounts.plist and manually removing the inactive accounts before saving and relaunching Mail appears to have corrected the issue.

I'm not certain whether to mark this as the answer or to delete this question as I'm not sure how useful this is likely to be; I suppose someone else may eventually find an SMTP server failing after somehow getting inactive IMAP accounts "stuck" in this way; I'm going to report it to Apple anyway as I can't even begin to imagine why this should have caused Mail to stop sending an SMTP password.

Solving this issue also allows me to now enable or disable the "Automatically detect and maintain account settings" option, not sure what to make of that but it's a damned menace so it's getting turned off.