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

error when reply to mail #142

Open DarkBuffalo opened 2 years ago

DarkBuffalo commented 2 years ago

Hi, First off all, thanks for this great project. ;-) When I reply to an email we don't see it in the email but we see it appear in the sources under the multipart/alternative part.

Is this a bug or misuse on my part ?

Screenshot

Capture d’écran du 2022-01-28 11-13-28

mail source:

`User-agent: mu4e 1.6.10; emacs 27.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-="

--=-=-= Content-Type: multipart/alternative; boundary="==-=-="

--==-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable

essai de r=C3=A9ponse

celle ci ne s=E2=80=99affiche pas.

pourquoi ?

Cordialement, =E2=80=93

Robert

--==-=-= Content-Type: text/html; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable

<html lang=3D"fr"><meta charset=3D"utf-8"/>

...

Cordialement,
=E2=80=93

<p style=3D"text-decoration:none;line-height:1.4;margin-top:10px;margin-bot= tom:0px;font-size:11pt;max-width:50em;"> Robert

--==-=-=--

--=-=-=--`

karamme commented 2 years ago

@DarkBuffalo I have the same problem. Did you find any solution for this?

DarkBuffalo commented 2 years ago

@DarkBuffalo I have the same problem. Did you find any solution for this?

@karamme Nop

DarkBuffalo commented 2 years ago

@DarkBuffalo I have the same problem. Did you find any solution for this?

My version of Emacs is 28. @karamme What is your version of emacs?

We should check, but I believe that the problem does not appear on version 27.

Perangelot commented 2 years ago

I have the same problem. Additionally, German umlauts are correctly displayed in the reply message, but not in the message thread below. When I send the message, I get "Message contains characters with unkonwn encoding. Really send?". If I press yes, I am asked whether to use the ASCII charset. Pressing "yes" yields an error message. Pressing "no" sends a message with umlauts not displayed correctly. For example, instead of "Mühe", M��he is displayed. In the buffer I get \301\274 instead of the question marks in "Mühe". In Thunderbird, it is displayed as MÁ¼he. Composing a normal non-reply-message works perfectly. Version is emacs 28.1.

karamme commented 2 years ago

I upgraded to Emacs 29 recently, but I also had the problem with Emacs 28. At work I run Emacs 27 and still have to problem. So I guess it is not a compatibility issue with Emacs. I use Doom Emacs. Unlike your example, when I reply I don't see nothing, but in the HTML version a line with "by first name surname" is inserted. If I turn debug-on-error on, there is unfortunately no error, which would make it easier.

@Perangelot I just tested umlauts in the thread, but this is working fine for me.

karamme commented 2 years ago

Alright, after same investigation, I could pinpoint what was causing the error. I once changed the variable org-html-preamble-format (ox-html) to include the date and author underneath the title for an html export. org-msg is using the same function to generate the html, but fails when a preamble is included. Resetting org-html-preamble-format or adding html-preamble:nil to org-msg-options does fix the issue for me.

opensource-philosophy commented 2 years ago

@karamme I am afraid this solution does not work for me. Could you test if you have problems with Umlauts like in "können", "Märchen", "Übung"?

And what is the output of (org-msg-export-as-html "Übung") for you?

Edit: I have found out the culprit. I had set (setq coding-system-for-read 'utf-8). Taking out this line does not produce the problem. The reason for that seems to be the last part of org-msg-save-article-for-reply-mu4e:

    (when-let ((xml (libxml-parse-html-region (point-min) (point-max)))
           (charset (catch 'found (org-msg-xml-walk xml #'get-charset))))
      (let ((coding (intern (downcase charset))))
        (when (coding-system-p coding)
          (setq save-buffer-coding-system coding))))

I can't understand how exactly this hinges on the value of coding-system-for-read. Any ideas?

karamme commented 2 years ago

@opensource-philosophy I just tried all kind of umlauts but never encountered a problem. I also tried after settings (setq coding-system-for-read 'utf-8) to reply to and with umlauts, but that also works on my setup. I have an umlaut in my signature, but they all render fine, with org-msg as well as mu4e default compose view.

I just checked my variables: coding-system-for-write, sendmail-coding-system, and org-export-coding-system are nil; org-html-coding-system and default-sendmail-coding-system are utf-8 and message-send-coding-system is binary. Do you have ASCII or something on one of those?

opensource-philosophy commented 2 years ago

Now I had the time to have a look at it. I realized that the problem arises in particular when replying to someone who wrote a mail in the browser with outlook.live.com. I had a look in the source code and the encoding happens not to be utf-8 but iso-8859-1. This is very strange because AFAIK utf-8 covers the whole iso-8859-1 charset. But by trial and error, I made sure that this line in the mail causes the problem:

<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">

Do you have an idea why is that? Changing org-html-coding-system does not make a difference.