Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions _build/data/transport.core.system_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,25 @@
'area' => 'mail',
'editedon' => null,
], '', true, true);
$settings['mail_inlinestyle_inline'] = $xpdo->newObject(modSystemSetting::class);
$settings['mail_inlinestyle_inline']->fromArray([
'key' => 'mail_inlinestyle_inline',
'value' => true,
'xtype' => 'combo-boolean',
'namespace' => 'core',
'area' => 'mail',
'editedon' => null,
], '', true, true);

$settings['mail_inlinestyle_remove_style_tags'] = $xpdo->newObject(modSystemSetting::class);
$settings['mail_inlinestyle_remove_style_tags']->fromArray([
'key' => 'mail_inlinestyle_remove_style_tags',
'value' => false,
'xtype' => 'combo-boolean',
'namespace' => 'core',
'area' => 'mail',
'editedon' => null,
], '', true, true);
$settings['manager_date_format'] = $xpdo->newObject(modSystemSetting::class);
$settings['manager_date_format']->fromArray([
'key' => 'manager_date_format',
Expand Down
6 changes: 6 additions & 0 deletions core/lexicon/en/setting.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@
$_lang['setting_mail_dkim_passphrase'] = 'DKIM Passphrase';
$_lang['setting_mail_dkim_passphrase_desc'] = 'Used only if your key is encrypted.';

$_lang['mail_inlinestyle_inline'] = 'InlineStyle: Enable style inlining for HTML emails';
$_lang['mail_inlinestyle_inline_desc'] = 'All styles from <style> tags will be inlined for HTML emails.';

$_lang['mail_inlinestyle_remove_style_tags'] = 'InlineStyle: Remove <style> tags';
$_lang['mail_inlinestyle_remove_style_tags_desc'] = 'After inlining styles, all &#x3C;style&#x3E; tags will be removed. <strong>Warning: This can cause issues with responsive email templates.</strong>';

$_lang['setting_main_nav_parent'] = 'Main menu parent';
$_lang['setting_main_nav_parent_desc'] = 'The container used to pull all records for the main menu.';

Expand Down
12 changes: 10 additions & 2 deletions core/src/Revolution/Mail/modPHPMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,21 @@ public function send(array $attributes = [])

$sent = false;
try {
if (!empty($this->mailer->Body) && (strpos($this->mailer->ContentType, 'html') !== false)) {
$inlineStyleEnabled = $this->modx->getOption('mail_inlinestyle_inline', null, true, true);
if (
$inlineStyleEnabled &&
!empty($this->mailer->Body) &&
(strpos($this->mailer->ContentType, 'html') !== false)
) {
$body = $this->mailer->Body;
// Turn UTF-8 characters into entities
$body = mb_convert_encoding($body, 'HTML-ENTITIES', 'UTF-8');
$html = new InlineStyle($body);
$removeStyleTags = (bool) $this->modx->getOption('mail_inlinestyle_remove_style_tags', null, false, true);
/** @noinspection PhpParamsInspection */
$html->applyStylesheet($html->extractStylesheets());
$html->applyStylesheet(
$html->extractStylesheets(null, '', ['all', 'screen', 'handheld'], $removeStyleTags),
);
$this->mailer->Body = $html->getHTML();
}
$sent = $this->mailer->send();
Expand Down