[%# Notes for email styles: - Microsoft Outlook does not display "HTML Email", it imports the HTML into a Microsoft Word document and renders that. So, email styling is more about what Microsoft Word is able to import than it is about correct HTML. - never put "margin" on a table element, because some Outlook versions will apply that to all of the table cells as well. - Outlook can't properly handle padding on anything other than a table cell - Outlook can only have "border:collapse" on tables. - never use "float" or absolute positioning - you can't reliably create @print styles, so make everything work on a 7.5" page - Outlook can't do centered fixed-width content without using a table, so the whole page needs wrapped in a table - the "Mkit" system will inline all these styles into the elements themselves, because some email clients don't handle classes well. %] #### [%# Outlook has goofy spacing on list item elements. CSS flattens it down, but then unindent to compensate for the default padding that we removed. %] [%# ----- PAGE WRAPPER ----- %] [%# MS Office cant handle css width, so need to wrap everything with a table %]
#### From: example To: example Subject: Example Date: Tue, 25 Mar 2025 13:02:21 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=17429257410.7ADB6.10260 Content-Transfer-Encoding: 7bit Message-ID: <17429257411.685ff8.10260@redacted.example.com> --17429257410.7ADB6.10260 Date: Tue, 25 Mar 2025 13:02:21 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Example --17429257410.7ADB6.10260 Date: Tue, 25 Mar 2025 13:02:21 -0500 MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Example ...
--17429257410.7ADB6.10260-- ##
## $text ||= HTML::FormatText::WithLinks->new(unique_links => 1)->parse($html); # Ugly workaround for WPEngine.com discriminating against perl my $real_new= Email::MIME::CreateHTML::Resolver::LWP->can('new'); local *Email::MIME::CreateHTML::Resolver::LWP::new= sub { my $self= $real_new->(@_); $self->{UA}->agent(q{We're your customer, dammit, stop blocking perl}); $self->{UA}->protocols_allowed(['http', 'https']); return $self; }; # Build the email. The resolver will find all external images and stylesheets # and suck them in as multiple parts. my $viewable= Email::MIME->create_html( header => [ ], # we use the unicode-enabled setters, instead text_body_attributes => { charset => 'UTF-8', encoding => 'quoted-printable' }, text_body => encode('UTF-8', $text), # text gets assigned as-is body_attributes => { charset => 'UTF-8', encoding => 'quoted-printable' }, body => $html, # body gets assigned as body_str embed => 1, base => "https://redacted.example.com", object_cache => $self->resource_cache, # Prevent excessive lookups of resources # Because most mail clients don't properly process