advice on mu4e-org-mode and org-mime-htmlize

1,238 views
Skip to first unread message

Victor A. Stoichita

unread,
Apr 25, 2019, 10:06:31 AM4/25/19
to mu-di...@googlegroups.com
Hi,

I’m revisiting the old problem of sending html emails using mu4e.
I’ve been trying to keep up with the tips and tricks shared on
this list for a few years, but now I’m a bit lost between the
modern/current way to do things and the deprecated ones.

Until recently I was using org-mu4e-compose-org-mode to compose
the text using org syntax, and then org-mime-htmlize to convert
the buffer to html before sending.

I realized that org-mu4e-compose-org-mode is now deprecated.
I then tried mu4-org-mode. It seems to merely turn the buffer into
an org-mode buffer. I was not able to discover any mu4e shortcuts
in it, and it also disables address completion. So I have to
return to plain mu4e-compose-mode to add an address and send the
email. Should I then just compose the message in plain old
mu4e-compose-mode, maybe with orgstruct-mode and orgstruct++-mode?

For the next step, which is converting the message to html,
org-mime-htmlize still works fine. But IIRC it formerly produced
two multipart message parts: one retained the plain text, the
other was the html version. Currently (Emacs 26.1, org-mode
9.1.9), the whole message becomes an html part (no more plain text
version). Attachments are also lost if I insert them before
htmlization as their code (<part> etc. </part>) is converted to
html symbols by org-mime-htmlize.

All this boils down to a question: what is the current/recommended
way to send html emails from mu4e?

In case it matters: I need html mainly because colleagues and
students expect italics in bibliographical references (when I cite
book titles for instance), and because html structured lists (like
"you have three choices: 1. … 2.… 3. …") are much clearer to read
in html. I suspect that it’s a pretty trivial use case?

Regards to all,
Victor

Dirk-Jan C. Binnema

unread,
Apr 25, 2019, 3:28:19 PM4/25/19
to mu-di...@googlegroups.com
Hi Victor,

On Thursday Apr 25 2019, Victor A. Stoichita wrote:

> Hi,
>
> I’m revisiting the old problem of sending html emails using mu4e. I’ve been
> trying to keep up with the tips and tricks shared on this list for a few years,
> but now I’m a bit lost between the modern/current way to do things and the
> deprecated ones.
>
> Until recently I was using org-mu4e-compose-org-mode to compose the text using
> org syntax, and then org-mime-htmlize to convert the buffer to html before
> sending.
>
> I realized that org-mu4e-compose-org-mode is now deprecated.

It's been so for a while already; the idea was to make org-mime a bit
more seamless; but there are a lot of seam, more than my time-budget
allowed.

> I then tried mu4-org-mode. It seems to merely turn the buffer into an
> org-mode buffer. I was not able to discover any mu4e shortcuts in it,
> and it also disables address completion. So I have to return to plain
> mu4e-compose-mode to add an address and send the email. Should I then
> just compose the message in plain old mu4e-compose-mode, maybe with
> orgstruct-mode and orgstruct++-mode?

mu4e-org-mode is an org-mode-derived mode that mu4e uses internally for
displaying some information, such as [N]ews and [A]bout mu4e in the main
screen. It's not useful for composing mail.

> For the next step, which is converting the message to html, org-mime-htmlize
> still works fine. But IIRC it formerly produced two multipart message parts: one
> retained the plain text, the other was the html version. Currently (Emacs 26.1,
> org-mode 9.1.9), the whole message becomes an html part (no more plain text
> version). Attachments are also lost if I insert them before htmlization as their
> code (<part> etc. </part>) is converted to html symbols by org-mime-htmlize.
>
> All this boils down to a question: what is the current/recommended way to send
> html emails from mu4e?

I guess org-mime is still the best way; if there are any issues with
that, those are probably best addressed to the org-mime maintainers.

Kind regards,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
gpg: 6987 9CED 1745 9375 0F14 DA98 11DD FEA9 DCC4 A036

Victor A. Stoichita

unread,
Apr 26, 2019, 4:49:58 AM4/26/19
to mu-di...@googlegroups.com
Hi Dirk,

Thanks for clarifying this. I’ll work with org-mime then.

In case anyone else wonders why there is no plain text body
anymore in the org-mime export, decision was taken to drop it:
https://github.com/org-mime/org-mime/issues/32
The caveat is that now if you org-mime just a region of the
buffer, that region won’t appear any longer to a plain text
reader. As I understand it, org-mime should now be applied to the
whole buffer or not at all. Indeed a discussion for the
org-mode list.

Cheers, and thanks for the ongoing work on mu!
Victor

Le 25 Apr 2019, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl>
a écrit :

Phil

unread,
May 14, 2019, 10:18:44 AM5/14/19
to mu-di...@googlegroups.com

Hi,

On this subject - in case people where unaware of the below links on the topics, thought I'd share them.

Also it would be great to collect all these ideas into a single repo, something I keep failing to do myself!


If anyone else has hints or tips regarding this - I'm really keen to hear them.



I use mu4e as my daily email program, and write rich-text-like emails using org mode.

It works well for code snippets, tables, bullets, etc, but it took a fair bit of tweaking to get it practically usable and secure as my day-to-day emailer.


I started following the advice:

https://matt.hackinghistory.ca/2016/11/18/sending-html-mail-with-mu4e/

http://kitchingroup.cheme.cmu.edu/blog/2016/10/29/Sending-html-emails-from-org-mode-with-org-mime/


I keep a (fairly) up-to-date forked version mu with tweaks to make org/html messaging easier taken from here:

https://github.com/titaniumbones/mu/tree/org-mu4e-compose-stabilization


Merged into latest-ish code here:

https://github.com/falloutphil/mu


I also have some other utils to help:

https://github.com/falloutphil/emacs-email



A few other useful techniques I don't have in github yet - I have lots more, which I write as and when something doesn't work quite right:


;; this is stolen from John but it didn't work for me until I                                                                                                                                                                                                               
;; made those changes to mu4e-compose.el                                                                                                                                                                                                                                    
(defun htmlize-and-send ()                                                                                                                                                                                                                                                  
  "When in an org-mu4e-compose-org-mode message, htmlize and send it."                                                                                                                                                                                                      
  (interactive)                                                                                                                                                                                                                                                             
  (when (member 'org~mu4e-mime-switch-headers-or-body post-command-hook)                                                                                                                                                                                                    
    (org-mime-htmlize)                                                                                                                                                                                                                                                      
    (org-mu4e-compose-org-mode)                                                                                                                                                                                                                                             
    (mu4e-compose-mode)                                                                                                                                                                                                                                                     
    (message-send-and-exit)))                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                            
;; This overloads the amazing C-c C-c commands in org-mode with one more function                                                                                                                                                                                           
;; namely the htmlize-and-send, above.                                                                                                                                                                                                                                      
(add-hook 'org-ctrl-c-ctrl-c-hook 'htmlize-and-send t)                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                            
;; Originally, I set the `mu4e-compose-mode-hook' here, but                                                                                                                                                                                                                 
;; this new hook works much, much better for me.                                                                                                                                                                                                                            
(add-hook 'mu4e-compose-post-hook                                                                                                                                                                                                                                           
          (defun do-compose-stuff ()                                                                                                                                                                                                                                        
            "My settings for message composition."                                                                                                                                                                                                                          
            (org-mu4e-compose-org-mode)))                                                                                                                                                                                                                                   
                                            

;; Instead of prefixing we just format the whole quoted message                                                                                                                                                                                                             
;; as verbatim text.  This means no characters can be misinterpreted                                                                                                                                                                                                        
;; as org mark-up.                                                                                                                                                                                                                                                          
(defun message-cite-original-without-signature-wrapped-example ()                                                                                                                                                                                                           
  "Modified version of message-cite-original-without-signature.                                                                                                                                                                                                             
This function wraps the reply in #+BEGIN_EXAMPLE and #+END_EXAMPLE.                                                                                                                                                                                                         
This prevents anything in the original message being misconstrued as mark-up."                                                                                                                                                                                              
  (message-cite-original-1 t)                                                                                                                                                                                                                                               
  (goto-char (point))                                                                                                                                                                                                                                                       
  (insert "#+BEGIN_EXAMPLE\n")                                                                                                                                                                                                                                              
  (goto-char (mark t))                                                                                                                                                                                                                                                      
  (insert "#+END_EXAMPLE"))                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                            
(setq mu4e-compose-cite-function 'message-cite-original-without-signature-wrapped-example)                                                                                                                                                                                  
                                                                                            

;; Signature in Org - it contains a wrapped HTML Signature                                                                                                                                                                                                         
;; It also includes includes for other org macros, as order is not                                                                                                                                                                                                          
;; important we can include at the end of the email message.                                                                                                                                                                                                                
(setq mu4e-compose-signature-auto-include t                                                                                                                                           
      mu4e-compose-signature "#+INCLUDE: \"/home/me/path/to/my/message-settings.org\"")     


My message-settings.org looks like this:

# Toggle TeX-like syntax for sub- and superscripts.                                                                                                                                                                                                                         
# If you write "^:{}", ‘a_{b}’ will be interpreted, but the simple ‘a_b’ will be left as it is (org-export-with-sub-superscripts).                                                                                                                                          
#+OPTIONS: ^:{}                                                                                                                                                                                                                                                             
#+OPTIONS: d:MACROS d:SIGNATURE                                                                                                                                                                                                                                             
:MACROS:                                                                                                                                                                                                                                                                    
#+INCLUDE: /home/me/path/to/org-macros/org-macros.setup                                                                                                                                                                                                               
:END:                                                                                                                                                                                                                                                                       
:SIGNATURE:                                                                                                                                                                                                                                                                 
# @@word: blah@@ means only export the blah when word is the export type                                                                                                                                                                                                    
# So here when exporting to html (i.e. always when writing an email), include the following raw text                                                                                                                                                                        
@@html:                                                                                                                                                                                                                                                                     
<html>ADD YOUR STANDARD HTML SIGNATURE HERE</html>

@@                                                                                                                                                                                                                                                                          
:END:

I get org-macros.setup from the below link - it's good for adding a bit of colour, etc, to emails:
signature.asc

Matt Price

unread,
May 29, 2019, 8:19:12 PM5/29/19
to mu-di...@googlegroups.com
This is really helpful, phil.  A bit embarrassing to see that ancient post of mine in your list.  Unfortunately the maintainer of org-mime is intent on supporting pretty old versions of Emacs, which means that every improvement has to be implemented in both the old (org 8.x) export structure, and the new (org 9.x). Since the old system is dramatically worse, and basically I can't write working code for it, I personally have stopped trying to submit PRs.  I also have a fork that I maintain, but looks like yours is more up to date.  

John Kitchin has an entirely different solution that he maintains as part of scimax. I'm super tired right now or I would find it for y'all!.

matt

--
You received this message because you are subscribed to the Google Groups "mu-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mu-discuss+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mu-discuss/6b9fd6ab-dab9-7df3-9d26-8f4c3529d58d%40beadling.co.uk.
For more options, visit https://groups.google.com/d/optout.

Matt Price

unread,
Aug 21, 2019, 3:50:04 PM8/21/19
to mu-di...@googlegroups.com
Does anyone want to collaborate a bit on a more usable solution for org-based html mail in mu4e? I've just been looking a bit at the current state of org-mim and it still is tested only on Emacs 25 and below (!), while org-msg entirely fails to generate html mails for me right now (haven't figured out why yet).

I'd love to get to the point where these two use cases were easy:

- quickly and easily email messages from an org buffer or subtree
- easily reply to HTML messages using org syntax

Right now, I have the first use case workingin in a fragile fork of org-mime, and the second use case kinda sorta works a little with org-mu4e-org-compose-mode..  It would be nice to have all the code for both use cases (a) properly maintained and (b) available in one place.  Maybe org-msg is the best place to start, but since I haven't had any success at all with it, I can't say for sure.  

Matt

Phil

unread,
Aug 21, 2019, 4:23:44 PM8/21/19
to mu-di...@googlegroups.com

I keep meaning to come back to this thread!

I'm interested and agree - having a single repo (or collection of repos) which implement/configure an org-based usable email system would be really useful.

I can compose messages from an org mode buffer and they look like pretty good when rendered as HTML to the recipient.  It's good enough that most the time colleagues who use Outlook cannot tell that I'm not using Outlook.

To reply to any message I always wrap the original message in BEGIN/END_EXAMPLE tags.  This is a cop-out, but it means whatever format it is in, it renders OK underneath my response in a readable way.  Without this occasionally my emails would render badly, and it was unusable as a serious system.

I'd too would like a system where when responding I respect the HTML/formatting of the original message.


I'm also interested in tighter integration with Outlook Calendar too - here  I can read my calendar into  my org agenda fine (using excorporate package), but I have no way of booking meetings from org agenda.

I've also got Skype for Business integrated well into Emacs too - but that's an even longer story.


All of my lisp code and config is in a haphazard bunch of files, and mixed up with more mundane emacs config.  I need some motivation to make it all generic and usable by anyone and not specific to my setup.  Over the course of several months I migrated off Microsoft and onto Emacs so everything was written bit-by-bit when I had a spare hour or so.  So it's a mess.


Phil.

signature.asc

Matt Price

unread,
Aug 22, 2019, 3:25:11 PM8/22/19
to mu-di...@googlegroups.com
hi Phil,

Thanks for reaching out. What do you think would be the best way to start?Do you think your code could be a good starting place?

Reply all
Reply to author
Forward
0 new messages