fix: show utf-8 mail body properly

This commit is contained in:
Felix Mosheev 2021-11-07 15:56:54 +02:00
parent 23a6aed10d
commit bfb4769e85
2 changed files with 7 additions and 9 deletions

View File

@ -4,8 +4,9 @@ class HtmlEmail extends HTMLElement {
this.attachShadow({ mode: 'open' });
let emailContent;
const templateId = this.dataset.templateId;
try {
emailContent = window.atob(this.dataset.content);
emailContent = document.getElementById(templateId).innerHTML;
} catch (error) {
console.log(error);
return;

View File

@ -186,8 +186,8 @@ $messages = $MyMbox->get($sortOrderArr);
<td></td>
<td colspan="4">
<?php if ($body !== null): ?>
<html-email data-content="<?php echo base64_encode($body) ?>">
</html-email>
<template id="mail-body-<?=$data['num']?>"><?=$body?></template>
<html-email data-template-id="mail-body-<?=$data['num']?>"></html-email>
<?php else: ?>
<div class="alert alert-warning" role="alert">
No valid body found
@ -213,12 +213,9 @@ $messages = $MyMbox->get($sortOrderArr);
<?php echo loadClass('Html')->getFooter(); ?>
<script>
$(function() {
$('.subject').each(function() {
$(this).click(function() {
var id = ($(this).attr('id'));
$('#mail-'+id).toggle();
})
$('.subject').click(function() {
var id = ($(this).attr('id'));
$('#mail-'+id).toggle();
})
// Handler for .ready() called.
});