premailer fails to run on emails when S/MIME signing is active
S/MIME signing is implemented as an ActionMailer interceptor that modifies the final message before delivery, and added in the initialization phase as the last one (when active).
premailer on the other hand is loaded implicitly (as a Railtie) and hooks itself at the very end of the interceptors list after initialization, but after the S/MIME interceptor:
> Mail.class_variable_get(:@@delivery_interceptors)
=> [Gitlab::Email::Hook::AdditionalHeadersInterceptor,
Gitlab::Email::Hook::EmailTemplateInterceptor,
Gitlab::Email::Hook::DeliveryMetricsObserver,
Gitlab::Email::Hook::SmimeSignatureInterceptor,
Premailer::Rails::Hook]
In principle, this should mangle all signatures, as the message would be modified after being signed and before delivery. But premailer ignores the signed emails, not modifying the contents. The net effect is a signed message but premailer not run, so the inline styles are not applied.
We have a local patch forcing the loading of premailer in the initialization and will be submitting an MR shortly.
Mentioning @engwan since he was involved in our discussions when creating the S/MIME signature feature and seems to know his way around premailer a lot.