lordpretzel / async-email-sending

Sending email asyncronously with Emacs
GNU General Public License v3.0
9 stars 0 forks source link

Crash on attempting to open bui queue #1

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago

Hi Boris! This looks great! I hope this gets integrated into mu4e/gnus at some point.

I ran into a crash after installing async-email-sending manually from src and performing the following actions:

  1. (require 'async-email-sending) (didn't enable async-email-sending yet)
  2. Attempted to send an email (got a prompt about setting outgoing smtp server)
  3. Enabled async-email-sending with customize-variable
  4. Sent a test email with a 700kB attachment
  5. Opened the BUI queue list, waited and refreshed it, email never sent
  6. Sent a second test email with no attachment
  7. Attempted to open the queue list again, got the following error:
Debugger entered--Lisp error: (void-function nil)
nil(("a473e223d875acf9aa2d6acda7d58e5b8e4185e3" ["Me <my@e.mail>" "Me <my@e.mail>" "Thu, 05 Jan 2023 00:29:47 -0800" "test async-email-sending" "—"]) ("420c6bde86d6597db56dd014be7c601f06547e4c" ["Me <my@e.mail>" "Me <my@e.mail>" "Thu, 05 Jan 2023 00:38:31 -0800" "test async-email-sending" "—"]))
#f(compiled-function (a b) #<bytecode 0x45e36f08ce3a9fb>)(("420c6bde86d6597db56dd014be7c601f06547e4c" ["Me <my@e.mail>" "Me <my@e.mail>" "Thu, 05 Jan 2023 00:38:31 -0800" "test async-email-sending" "—"]) ("a473e223d875acf9aa2d6acda7d58e5b8e4185e3" ["Me <my@e.mail>" "Me <my@e.mail>" "Thu, 05 Jan 2023 00:29:47 -0800" "test async-email-sending" "—"]))
tabulated-list-print()
bui-list-insert-entries((((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) async-email-sending-queued-mail-bui-entries)
bui-insert-entries((((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) async-email-sending-queued-mail-bui-entries list)
bui-show-entries-default((((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) async-email-sending-queued-mail-bui-entries list)
bui-show-entries((((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) async-email-sending-queued-mail-bui-entries list)
bui-set(#s(bui-item :entries (((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) :entry-type async-email-sending-queued-mail-bui-entries :buffer-type list :args nil) nil)
bui-display-entries-current((((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) async-email-sending-queued-mail-bui-entries list nil nil)
bui-display-entries((((id . "a473e223d875acf9aa2d6acda7d58e5b8e4185e3") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "UklGRlCGCwBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAASU...") (date . "Thu, 05 Jan 2023 00:29:47 -0800") (emsg)) ((id . "420c6bde86d6597db56dd014be7c601f06547e4c") (from . "Me <my@e.mail>") (to . "Me <my@e.mail>") (subject . "test async-email-sending") (content . "test\n") (date . "Thu, 05 Jan 2023 00:38:31 -0800") (emsg))) async-email-sending-queued-mail-bui-entries list nil nil)
bui-get-display-entries(async-email-sending-queued-mail-bui-entries list)
async-email-sending-queued-mail-show-bui()
funcall-interactively(async-email-sending-queued-mail-show-bui)
command-execute(async-email-sending-queued-mail-show-bui record)
execute-extended-command(nil "async-email-sending-queued-mail-show-bui" nil)
funcall-interactively(execute-extended-command nil "async-email-sending-queued-mail-show-bui" nil)
command-execute(execute-extended-command)

I am on Emacs 29 with mu4e.

Hope this is useful!

Joseph

lordpretzel commented 1 year ago

Hi Joseph,

this is some issue with the bui library that I faced before, but have not clue what is causing it. Regarding mail sending, can you let me know a few things that will help me debug:

Best,

Boris

josephmturner commented 1 year ago

I tried M-: (async-email-sending-send-mail-async) from within the draft buffer. This has the same effect as attempting to send the mail normally after enabling async-email-sending with customize: the email is not sent, and list-processes displays a new child *emacs* process. Inspecting the child process reveals

Lisp expression: Warning (defvaralias): Overwriting value of `epg-bug-report-address' by aliasing to `report-emacs-bug-address'
Outgoing SMTP mail server: 

The values of send-mail-function and message-send-mail-function are both async-email-sending-send-mail-async.

I'm not sure the best way to check that the advice is set correctly. What I did was instrument async-email-sending-advice-add-if-def for Edebug before enabling async-email-sending with customize. The following advices are set:

(advice-add mu4e--main-queue-size :override async-email-sending--num-queued-emails)
(advice-add smtpmail-send-queued-mail :override async-email-sending--flush-queued-emails)
lordpretzel commented 1 year ago

So the good news is that the async code was actually executed. I suspect the issue is related to epa trying to access your credentials and as there is no user interaction with the emacs process that async spawns, it will fail to do so. I remember reading something about authentification problems with the https://github.com/jwiegley/emacs-async/blob/master/smtpmail-async.el package. I have to find that comment again and see what can be done about this.

lordpretzel commented 1 year ago

Looks like I was wrong. Emacs is trying to ask you for an smtp server in smtpmail-via-smtp to send from interactively and gets stuck. From smtpmail.el:

  (unless smtpmail-smtp-server
    (smtpmail-query-smtp-server))

and gets stuck here as we can see based on the output of the process you posted:

(defun smtpmail-query-smtp-server ()
  "Query for an SMTP server and try to contact it.
If the contact succeeds, customizes and saves `smtpmail-smtp-server'
and `smtpmail-smtp-service'.  This tries standard SMTP ports, and if
none works asks you to supply one.  If you know that you need to use
a non-standard port, you can set `smtpmail-smtp-service' in advance.
Returns an error if the server cannot be contacted."
  (let ((server (read-string "Outgoing SMTP mail server: "))

I've pushed an update that should fix the bui interface and that makes sure that smtpmail-smtp-server is set before the async call. Hopefully that will fix things.

josephmturner commented 1 year ago

My (obvious) problem is that my sendmail-program is "msmtp". After converting my set-up to smtpmail and re-testing, I'll let you know if the problem goes away.

josephmturner commented 1 year ago

I spent a few hours in vain today trying to set up smtpmail with multiple maildirs. I've resolved to stick with msmtp for now. Sorry I can't be of more help to you! I hope to see this project succeed!