refactor: beautify SMTP email style

This commit is contained in:
moonrailgun 2024-02-09 19:39:12 +08:00
parent 8d096d55e1
commit 461e23be2f
2 changed files with 36 additions and 1 deletions

View File

@ -45,7 +45,42 @@ export const smtp: NotificationProvider = {
cc: payload.cc, cc: payload.cc,
bcc: payload.bcc, bcc: payload.bcc,
subject: subject, subject: subject,
html: bodyTextContent, html: generateSMTPHTML(bodyTextContent),
}); });
}, },
}; };
function generateSMTPHTML(message: string) {
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tianji</title>
<style>
img {
max-width: 100%;
}
</style>
</head>
<body style="background-color: #fafafa;">
<div style="width: 640px; margin: auto;">
<header style="margin-bottom: 10px; text-align: center;">
<img src="https://tianji.msgbyte.com/img/logo@128.png" width="50" height="50" />
</header>
<div style="background-color: #fff; border: 1px solid #dddddd; padding: 36px; margin-bottom: 10px;">
${message}
</div>
<footer style="text-align: center;">
<div>
Sent with by Tianji.
</div>
<div>
<a href="https://github.com/msgbyte/tianji" target="_blank">Github</a>
</div>
</footer>
</div>
</body>
</html>
`;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB