~janbaudisch/epistula

ref: 6f1e423b618e64ca10741b70712b315fda9e595a epistula/src/request.rs -rw-r--r-- 523 bytes
6f1e423bJan Baudisch builds: use archlinux 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::Config;
use lettre::SendableEmail;
use lettre_email::Email;
use serde::{Deserialize, Serialize};

#[derive(Clone, Deserialize, Serialize)]
pub struct Request {
    pub from: String,
    pub body: String,
}

impl Request {
    pub fn into_mail(self, config: Config) -> SendableEmail {
        Email::builder()
            .to(config.smtp_to)
            .from(self.from)
            .subject(config.smtp_subject)
            .text(self.body)
            .build()
            .unwrap()
            .into()
    }
}