mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
Resolve #245 Send HTML message as last part
This commit is contained in:
parent
f2054fde0f
commit
93dcea6d35
2 changed files with 21 additions and 16 deletions
|
|
@ -414,6 +414,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
.replace(/(<[^>]+)\s+data-hs-[a-z-]+=("[^"]+"|'[^']+')/gi, '$1');
|
||||
} while (l != Text.length)
|
||||
params.Html = Text;
|
||||
params.Text = htmlToPlain(Text);
|
||||
} else {
|
||||
params.Text = Text;
|
||||
}
|
||||
|
|
@ -428,13 +429,14 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
data.headers['Content-Transfer-Encoding'] = 'base64';
|
||||
data.body = base64_encode(Text);
|
||||
if (TextIsHtml) {
|
||||
let alternative = new MimePart;
|
||||
const alternative = new MimePart, plain = new MimePart;
|
||||
alternative.headers['Content-Type'] = 'multipart/alternative';
|
||||
alternative.children.push(data);
|
||||
data = new MimePart;
|
||||
data.headers['Content-Type'] = 'text/plain; charset="utf-8"';
|
||||
data.headers['Content-Transfer-Encoding'] = 'base64';
|
||||
data.body = base64_encode(htmlToPlain(Text));
|
||||
plain.headers['Content-Type'] = 'text/plain; charset="utf-8"';
|
||||
plain.headers['Content-Transfer-Encoding'] = 'base64';
|
||||
plain.body = base64_encode(params.Text);
|
||||
// First add plain
|
||||
alternative.children.push(plain);
|
||||
// Now add HTML
|
||||
alternative.children.push(data);
|
||||
data = alternative;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1167,16 +1167,9 @@ trait Messages
|
|||
|
||||
$sHtml = \MailSo\Base\HtmlUtils::BuildHtml($sHtml, $aFoundCids, $aFoundDataURL, $aFoundContentLocationUrls);
|
||||
$this->Plugins()->RunHook('filter.message-html', array($oAccount, $oMessage, &$sHtml));
|
||||
$oAlternativePart = new MimePart;
|
||||
$oAlternativePart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, 'text/html; charset=utf-8');
|
||||
$oAlternativePart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING, 'quoted-printable');
|
||||
$oAlternativePart->Body = \MailSo\Base\StreamWrappers\Binary::CreateStream(
|
||||
\MailSo\Base\ResourceRegistry::CreateMemoryResourceFromString(\preg_replace('/\\R/', "\r\n", \trim($sHtml))),
|
||||
'convert.quoted-printable-encode'
|
||||
);
|
||||
$oPart->SubParts->append($oAlternativePart);
|
||||
|
||||
$sPlain = \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sHtml);
|
||||
// First add plain
|
||||
$sPlain = $this->GetActionParam('Text', '') ?: \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sHtml);
|
||||
$this->Plugins()->RunHook('filter.message-plain', array($oAccount, $oMessage, &$sPlain));
|
||||
$oAlternativePart = new MimePart;
|
||||
$oAlternativePart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, 'text/plain; charset=utf-8');
|
||||
|
|
@ -1186,10 +1179,20 @@ trait Messages
|
|||
'convert.quoted-printable-encode'
|
||||
);
|
||||
$oPart->SubParts->append($oAlternativePart);
|
||||
unset($sPlain);
|
||||
|
||||
// Now add HTML
|
||||
$oAlternativePart = new MimePart;
|
||||
$oAlternativePart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, 'text/html; charset=utf-8');
|
||||
$oAlternativePart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING, 'quoted-printable');
|
||||
$oAlternativePart->Body = \MailSo\Base\StreamWrappers\Binary::CreateStream(
|
||||
\MailSo\Base\ResourceRegistry::CreateMemoryResourceFromString(\preg_replace('/\\R/', "\r\n", \trim($sHtml))),
|
||||
'convert.quoted-printable-encode'
|
||||
);
|
||||
$oPart->SubParts->append($oAlternativePart);
|
||||
|
||||
unset($oAlternativePart);
|
||||
unset($sHtml);
|
||||
unset($sPlain);
|
||||
|
||||
} else {
|
||||
$sPlain = $this->GetActionParam('Text', '');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue