$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