Subject: Use smtpmail-smtp-user if auth-source-search doesn't return user field

From: Jun Hao <[email-masked]>
Date: Sat, 27 Feb 2016 15:52:24 +0800

Hi,

On OSX when calling auth-source-search to search from keychain with
account has '\' in it, the function doesn't return user info back but
only password. This patch is to fix smtpmail if for whatever reason
above situation happened.

Long term is to fix auth-source-search. Looks like it missed this case
in auth-source-macos-keychain-search-items. If account has '\' in it,
security will return something like:

"acct"<blob>=0x414E545C6A756E68616F  "ANT\134junhao"

instead of form current code expects:

"acct"<blob>="junhao"

Even auth-source-search is fixed, I still think this patch is nice
to have to make smtpmail more robust.

Thanks - Jun

>From 6306eddd9bf0fe3b47ea4139337792761d32a61b Mon Sep 17 00:00:00 2001
From: Jun Hao <[email-masked]>
Date: Sat, 27 Feb 2016 15:01:35 +0800
Subject: [PATCH] Use default user if auth search doesn't return one

* smtpmail.el (smtpmail-try-auth-methods):Use smtpmail-smpt-user if
auth-source-search doesn't return user field

Copyright-paperwork-exempt: yes
---
 lisp/mail/smtpmail.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 8e0bb3a..be9807f 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -505,7 +505,7 @@ The list is in preference order.")
 		      :require (and ask-for-password
 				    '(:user :secret))
 		      :create ask-for-password)))
-         (user (plist-get auth-info :user))
+         (user (or (plist-get auth-info :user) smtpmail-smtp-user))
          (password (plist-get auth-info :secret))
 	 (save-function (and ask-for-password
 			     (plist-get auth-info :save-function)))
-- 
2.7.2