1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::delivery_result::DeliveryResult;

/// Per-Recipient Delivery Information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InternalRecipientStatus {
    /// The recipient's email address (for display)
    pub email_addr: String,

    /// The recipient's email address (for SMTP)
    pub smtp_email_addr: String,

    /// The domain parsed off of the recipients email address
    pub domain: String,

    /// The MX servers for the domain (as domain names), in order of delivery
    /// preference. If this is None, they have not been determined yet (DNS
    /// lookups take time).
    pub mx_servers: Option<Vec<String>>,

    /// The index into the MX server we are currently trying next
    pub current_mx: usize,

    /// The delivery result (so far) for this recipient
    pub result: DeliveryResult,
}

impl InternalRecipientStatus {
    pub fn as_recipient_status(&self) -> RecipientStatus {
        RecipientStatus {
            recipient: self.email_addr.clone(),
            result: self.result.clone(),
        }
    }
}

/// Per-Recpiient Delivery Information
#[derive(Debug, Serialize, Deserialize)]
pub struct RecipientStatus {
    pub recipient: String,
    pub result: DeliveryResult,
}