Using font-lock-mode with search based fontification can do this. For this to work the to address must be displayed in the buffer on the header line. It can be way over to the right where it is out of sight though. Because the :to field is often displayed as the recipients name this also requires a custom header field that displays the real to address to be set up in mu4e.
First the custom header field:
(add-to-list 'mu4e-header-info-custom
'(:real-to .
(:name "Real :to Address"
:shortname "realto"
:help ":to address without any aliases"
:function (lambda (msg)
(cdr (nth 0 (mu4e-message-field msg :to)))))))
Next setup the headers display:
(setq mu4e-headers-fields
'((:human-date . 12)
(:flags . 6)
(:from . 22)
(:subject . 80)
(:real-to . nil)))
At this point the new custom header field should be visible in the mu4e headers buffer. Then the regexp patterns need to be set up to match the email addresses. These patterns will match the address anywhere on the line but could be simplified a little just to match the pattern on the end of the line:
(setq header-highlights
'((".*public@mydomain.*" . email-public-face)
(".*teacher@mydomain.*" . email-teacher-face)
(".*iain@mydomain.*" . email-iain-face)
(".*photos@mydomain.*" . email-photos-face)
(".*[email protected].*" . email-wiserobot-face)
(".*@hotmail.com.*" . email-hotmail-face)
(".*\\([email protected]\\|[email protected]\\).*" . email-me-face)))
(add-hook 'mu4e-headers-mode-hook
(lambda ()
(setq font-lock-defaults '(header-highlights))))
Note that this is using custom faces. This is not necessary, any predefined face would do, but then redoing colour schemes might get confusing. I will include my code for completeness, but there is probably a neater way to do it. I had to define variables for each face which I don't think is supposed to be necessary.
(defface email-public
'((t :foreground "#bf9f00"))
"Face for mail headers to public@mydomain"
:group `basic-faces)
(defface email-teacher
'((t :foreground "#9f009f"))
"Face for mail headers to Teacher@mydomain"
:group 'basic-faces)
(defface email-iain
'((t :foreground "#009f00"))
"Face for mail headers to iain@mydomain"
:group 'basic-faces)
(defface email-photos
'((t :foreground "#ef1010"))
"Face for mail headers to photos@mydomain"
:group 'basic-faces)
(defface email-wiserobot
'((t :foreground "#0000e8"))
"Face for mail headers to iain@workdomain"
:group 'basic-faces)
(defface email-hotmail
'((t :foreground "#7840f8"))
"Face for mail headers to [email protected]"
:group 'basic-faces)
(defface email-me
'((t :foreground "#00c080"))
"Face for mail headers to [email protected]"
:group 'basic-faces)
(setq email-public-face `email-public
email-teacher-face 'email-teacher
email-iain-face 'email-iain
email-photos-face 'email-photos
email-wiserobot-face 'email-wiserobot
email-hotmail-face 'email-hotmail
email-me-face 'email-me)