feat: email template
This commit is contained in:
parent
81b233a047
commit
0f9b439b78
54
email.html
Normal file
54
email.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>LNVPS</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"/>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
font-family: "Source Code Pro", monospace;
|
||||
color: white;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.page {
|
||||
margin-left: 4rem;
|
||||
margin-right: 4rem;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
gap: 2rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 3rem;
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
p {
|
||||
min-height: 200px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
<div class="header">
|
||||
LNVPS
|
||||
<img height="48" src="https://lnvps.net/logo.jpg" alt="logo"/>
|
||||
</div>
|
||||
<hr/>
|
||||
<p>%%_MESSAGE_%%</p>
|
||||
<hr/>
|
||||
<small>
|
||||
(c) 2024 LNVPS.net
|
||||
</small>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -5,7 +5,7 @@ use crate::settings::{Settings, SmtpConfig};
|
||||
use crate::status::{VmRunningState, VmState, VmStateCache};
|
||||
use anyhow::Result;
|
||||
use chrono::{Days, Utc};
|
||||
use lettre::message::MessageBuilder;
|
||||
use lettre::message::{MessageBuilder, MultiPart};
|
||||
use lettre::transport::smtp::authentication::Credentials;
|
||||
use lettre::AsyncTransport;
|
||||
use lettre::{AsyncSmtpTransport, Tokio1Executor, Transport};
|
||||
@ -224,7 +224,13 @@ impl Worker {
|
||||
if let Some(f) = &smtp.from {
|
||||
b = b.from(f.parse()?);
|
||||
}
|
||||
let msg = b.body(message)?;
|
||||
let template = include_str!("../email.html");
|
||||
let html = MultiPart::alternative_plain_html(
|
||||
message.clone(),
|
||||
template.replace("%%_MESSAGE_%%", &message),
|
||||
);
|
||||
|
||||
let msg = b.multipart(html)?;
|
||||
|
||||
let sender = AsyncSmtpTransport::<Tokio1Executor>::relay(&smtp.server)?
|
||||
.credentials(Credentials::new(
|
||||
|
Loading…
x
Reference in New Issue
Block a user