I use mu4e and a fork of mu4e-send-delay. When I send a message and it gets sent after the queue timer runs, it is not longer in the Drafts folder, but neither is it in the Sent Items folder. The message only appears in Sent Items if I run a mu4e update, e.g. M-x mu4e-update-mail-and-index.

The source code has this function that sends mail and seems to return t at the end if successful:

(defun mu4e-send-delay-send-if-due (mail-file-path)
  "Send mail when MAIL-FILE-PATH contains scheduled time earlier
than current time and is not currently being edited."
  (when (and (mu4e-send-delay-elapsed-p mail-file-path)
             (not (mu4e-send-delay-file-buffer-open mail-file-path)))
    (if (not (mu4e-internet-up-p))
    (message "mu4e: unable to send queued message for lack of internet connection")
      (condition-case err
          (insert-file-contents-literally mail-file-path)

          ;; force recode to fix character encoding issue
          (set-buffer-file-coding-system 'utf-8 t)
          (recode-region (point-min) (point-max) 'prefer-utf-8 'utf-8-unix)

          (when mu4e-send-delay-strip-header-before-send
        (message-remove-header mu4e-send-delay-header nil t))
          ;; set modified to nil so buffer can be killed
          (set-buffer-modified-p nil))
        (mu4e-send-delay-move-to-sent-and-delete-draft mail-file-path)
    (error "mu4e-send: %s" err)))))

and this function is called by another function, which should run mu4e-update-index if any of the above calls returns t:

(defun mu4e-send-delay-send-queue ()
  "Send all delayed mails that are due now."
  (let ((dirs (if mu4e-contexts
                  (mapcar (lambda (context)
                            (mu4e-send-delay-with-mu4e-context context
                (list (mu4e-send-delay-get-drafts-folder)))))
    (when (memq t
                (mapcar (lambda (dir)
                          (cl-loop for file in (directory-files dir t "^[^\.]")
                                   collect (mu4e-send-delay-send-if-due file)))
      ;; only update index if something was done

I changed the last line to mu4e-update-mail-and-index and added a message before and after:

      (message "something was done before!")
      (message "something was done after!")

and I see none of these messages in the mini-buffer (only Sending mail and then Wrote /path/to/maildir/Sent Items/...), so I think that the first function is not returning t when a message sends successfully. I know some LISP but not enough to understand why or to debug it. Can someone help?

  • Done, I copy-pasted into a buffer and ran indent-region, then pasted back. – miguelmorin Jul 1 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.