I'm working on Emacs 29.1 at MacOs BigSur
I have a mu4e smtp account setup in ~/.authinfo
machine server1 login mail_users password pass1 port 587
machine server1 login user_admin password pass2 port 587
machine server2 login login2 password pass3 port 587
machine server3 login login3 password pass4 port 587
When I use server1 and server2 send mails works. When I'm adding the fourth entry server3 I get the strange message
Unexpected ‘machine’ token at line 4
OK line 4 has a classical structure and obviously machine token is correct one to put it at the beginning of the line.
For all 4 machine entries corresponding configurations for thunderbird working.
Question 1: What causes that error because despite of having smtpmail-debug-info t
and smtpmail-debug-verb t
. There is no info where can I find it.
Question 2: I'm really frustrated now, since 2 days I try to say Emacs to read 16 simple parameter which you can do in the most E-Mail programs in minutes. Is there a possibility to get rid of theseauth-source-netrc-parse-entries
mechanism using implicit filenames and showing an a-functional behavior in terms of querying, reporting states and errors, debugging and parsing.
EDIT
file stored as .authinfo.test
machine mx.server1.de login [email protected] password #ABCDE port 587
machine mx.server2.de login [email protected] password #EFGHI port 587
machine mx.server2.de login [email protected] password #4567; port 587
machine smtp.web123.de login web1234 password #1234 port 587
Call
(auth-source-netrc-parse
:file
(expand-file-name "~/.authinfo.test"))
auth-source-netrc-parse: using CACHED file data for /Users/i4w/.authinfo.test
if: auth-source-netrc-parse-entries: Unexpected ‘machine’ token at line 2
Debug version of auth-source-netrc-parse
I poked the function out of the auth.el
context
(setq auth-source-debug 'trivia)
(defalias 'auth-crab 'auth-source-netrc-parse-entries)
(defun auth-source-netrc-parse-entries(check max)
"Parse up to MAX netrc entries, passed by CHECK, from the current buffer."
(auth-source-do-trivia "\nBEGIN.PARSE")
(let ((adder (lambda(check alist all)
(when (and
alist
(> max (length all))
(funcall check alist))
(push alist all))
all))
item item2 all alist default)
(while (setq item (auth-source-netrc-parse-one))
(auth-source-do-trivia "\n BEGIN.WHILE")
(auth-source-do-trivia " PARSED.ITEM: %s" item)
(setq default (equal item "default"))
(auth-source-do-trivia " DEFAULT: %s" default)
;; We're starting a new machine. Save the old one.
(when (and alist
(or default
(equal item "machine")))
(auth-source-do-trivia " COLLECT.MACHINE: %S" alist)
(setq all (funcall adder check alist all)
alist nil))
(auth-source-do-trivia " RESULT: %S" all)
;; In default entries, we don't have a next token.
;; We store them as ("machine" . t)
(if default
(push (cons "default.machine" t) alist)
;; Not a default entry. Grab the next item.
(auth-source-do-trivia " COLLECT.DEFAULT: %S" alist)
(when (setq item2 (auth-source-netrc-parse-one))
;; Did we get a "machine" value?
(if (equal item2 "machine")
(progn
(auth-source-do-trivia
" ERROR: %s" (auth-source-current-line))
(error
"%s: Unexpected `machine' token at line %d"
"auth-source-netrc-parse-entries"
(auth-source-current-line)))
(push (cons item item2) alist))))
(auth-source-do-trivia " END.WHILE\n"))
;; Clean up: if there's an entry left over, use it.
(when alist
(setq all (funcall adder check alist all)))
(auth-source-do-trivia
"\nEND.PARSE.ALL")
(auth-source-do-trivia
"\nRESULT.ALL: %S" (nreverse all))
(nreverse all)))
Result with the invalid config
auth-source-netrc-parse: using CACHED file data for /Users/i4w/.authinfo.test
BEGIN.PARSE
BEGIN.WHILE
PARSED.ITEM: machine
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: nil
END.WHILE
BEGIN.WHILE
PARSED.ITEM: login
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("machine" . "mx.server1.de"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: password
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("login" . "[email protected]") ("machine" . "mx.server1.de"))
ERROR: 2
progn: auth-source-netrc-parse-entries: Unexpected ‘machine’ token at line 2
Result with a valid one
machine server1 login [email protected] password PWD.U1 port 587
machine server1 login [email protected] password PWD.U2 port 587
machine server2 login user3 password PWD.U3 port 587
machine server3 login user4 password PWD.U4 port 587
BEGIN.PARSE
BEGIN.WHILE
PARSED.ITEM: machine
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: nil
END.WHILE
BEGIN.WHILE
PARSED.ITEM: login
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("machine" . "server1"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: password
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("login" . "[email protected]") ("machine" . "server1"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: port
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("password" . "PWD.U1") ("login" . "[email protected]") ("machine" . "server1"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: machine
DEFAULT: nil
COLLECT.MACHINE: (("port" . "587") ("password" . "PWD.U1") ("login" . "[email protected]") ("machine" . "server1"))
RESULT: nil
COLLECT.DEFAULT: nil
END.WHILE
BEGIN.WHILE
PARSED.ITEM: login
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("machine" . "server1"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: password
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("login" . "[email protected]") ("machine" . "server1"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: port
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("password" . "PWD.U2") ("login" . "[email protected]") ("machine" . "server1"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: machine
DEFAULT: nil
COLLECT.MACHINE: (("port" . "587") ("password" . "PWD.U2") ("login" . "[email protected]") ("machine" . "server1"))
RESULT: nil
COLLECT.DEFAULT: nil
END.WHILE
BEGIN.WHILE
PARSED.ITEM: login
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("machine" . "server2"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: password
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("login" . "user3") ("machine" . "server2"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: port
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("password" . "PWD.U3") ("login" . "user3") ("machine" . "server2"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: machine
DEFAULT: nil
COLLECT.MACHINE: (("port" . "587") ("password" . "PWD.U3") ("login" . "user3") ("machine" . "server2"))
RESULT: nil
COLLECT.DEFAULT: nil
END.WHILE
BEGIN.WHILE
PARSED.ITEM: login
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("machine" . "server3"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: password
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("login" . "user4") ("machine" . "server3"))
END.WHILE
BEGIN.WHILE
PARSED.ITEM: port
DEFAULT: nil
RESULT: nil
COLLECT.DEFAULT: (("password" . "PWD.U4") ("login" . "user4") ("machine" . "server3"))
END.WHILE
END.PARSE.ALL
RESULT.ALL: nil
nil
.authinfo
syntax is not correct: you're missing thelogin
keyword in front of the username for each entryauth-source-netrc-parse
which triggers the error and to bring in some parser states to for debugging. The code makes abolute no sense to me especially when the collected data resultall
isnil
see ### EDIT