jeremy-compostella / org-msg

OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
GNU General Public License v3.0
276 stars 57 forks source link

Plain UTF-8 email with no attachments sent as multipart/mixed #141

Open hpfr opened 2 years ago

hpfr commented 2 years ago

I've composed a reply to an email with no attachments and only (utf-8) for alternatives.

When I send the message, it is sent as Content-Type: multipart/mixed, even though it only has one part, the body.

I did some basic debugging of org-msg-prepare-to-send (where I found (mml-insert-multipart "mixed")) and it looks like org-msg-build-alternatives returns a list with "text/plain" for the only alternative, nil for attachments, and "" for MML.

I believe the empty MML string is truthy, so multipart/mixed is inserted. Assuming I fully understand what's going on with MML (a poor assumption), is it possible to update this check to something like (or attachments (not (string-empty-p mml))) so that text/plain is sent instead? I would send a patch, but again I'm not fully sure if I understand what's going on with MML.

As an aside, what is MML for? It looks like it was added in May, and although I can tell there are functions for parsing it, I'm not sure how MML gets into an OrgMsg buffer in the first place. What do you use it for, out of curiosity? Or is it a Gnus-only thing?

Thanks for your work on this package!

IGJoshua commented 2 years ago

+1 for getting this fixed. When working on items with sr.ht it requires that emails be text/plain and never multipart. Without this being fixed you simply can't use org-msg for dealing with sourcehut.

A temporary fix is the following:

(defun +org-msg-separate-mml-and-org/remove-empty-mml (orig &rest args)
  (cl-multiple-value-bind (mml org)
      (apply orig args)
    (cl-values
     (if (string-empty-p mml)
         nil
       mml)
     org)))
(advice-add 'org-msg-separate-mml-and-org :around '+org-msg-separate-mml-and-org/remove-empty-mml)