1#[derive(Debug, Clone)]
2pub struct MailConfig {
3 pub driver: String,
5 pub from_address: String,
7 pub from_name: String,
9 pub reply_to: Option<String>,
11 pub smtp_host: Option<String>,
13 pub smtp_port: u16,
15 pub smtp_username: Option<String>,
17 pub smtp_password: Option<String>,
19 pub smtp_encryption: String,
21 pub postmark_api_key: Option<String>,
23 pub resend_api_key: Option<String>,
25}
26
27impl MailConfig {
28 pub fn from(mut self, address: impl Into<String>, name: impl Into<String>) -> Self {
30 self.from_address = address.into();
31 self.from_name = name.into();
32 self
33 }
34
35 pub fn reply_to(mut self, address: impl Into<String>) -> Self {
37 self.reply_to = Some(address.into());
38 self
39 }
40
41 pub fn smtp_host(mut self, host: impl Into<String>) -> Self {
43 self.smtp_host = Some(host.into());
44 self
45 }
46
47 pub fn smtp_port(mut self, port: u16) -> Self {
49 self.smtp_port = port;
50 self
51 }
52
53 pub fn postmark_key(mut self, key: impl Into<String>) -> Self {
55 self.postmark_api_key = Some(key.into());
56 self
57 }
58
59 pub fn resend_key(mut self, key: impl Into<String>) -> Self {
61 self.resend_api_key = Some(key.into());
62 self
63 }
64}
65
66impl Default for MailConfig {
67 fn default() -> Self {
68 Self {
69 driver: "log".into(),
70 from_address: "noreply@rok-app.com".into(),
71 from_name: "rok-app".into(),
72 reply_to: None,
73 smtp_host: None,
74 smtp_port: 587,
75 smtp_username: None,
76 smtp_password: None,
77 smtp_encryption: "starttls".into(),
78 postmark_api_key: None,
79 resend_api_key: None,
80 }
81 }
82}