1use crate::{Email, MailerError, Transport};
4
5#[derive(Clone, Copy, Debug, Default)]
7pub struct NullTransport;
8
9impl NullTransport {
10 #[must_use]
12 pub const fn new() -> Self {
13 Self
14 }
15}
16
17impl Transport for NullTransport {
18 fn send(&self, email: &Email) -> Result<(), MailerError> {
19 validate_for_send(email)
20 }
21}
22
23pub fn validate_for_send(email: &Email) -> Result<(), MailerError> {
24 if email.from_addresses().is_empty() {
25 return Err(MailerError::MissingSender);
26 }
27 if email.to_addresses().is_empty()
28 && email.cc_addresses().is_empty()
29 && email.bcc_addresses().is_empty()
30 {
31 return Err(MailerError::MissingRecipient);
32 }
33 Ok(())
34}