1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
19pub enum StatusCodes {
20 HelpMessage = 214,
22 SMTPServiceReady = 220,
24 ServiceClosingTransmissionChannel = 221,
26 AuthenticationSuccessful = 235,
28 OK = 250,
30 UserNotLocalWillForward = 251,
32 CannotVerifyUserButWillAcceptMessageAndAttemptDelivery = 252,
34
35 StartMailInput = 354,
37
38 ServiceNotAvailable = 421,
40 RequestedMailActionNotTakenMailboxUnavailable = 450,
42 RequestedActionAbortedLocalErrorInProcessing = 451,
44 InsufficientSystemStorage = 452,
46 ServerUnableToAccommodateParameters = 455,
48
49 SyntaxError = 500,
51 SyntaxErrorInParametersOrArguments = 501,
53 CommandNotImplemented = 502,
55 BadSequenceOfCommands = 503,
57 CommandParameterNotImplemented = 504,
59 ServerDoesNotAcceptMail = 521,
61 AuthenticationCredetialsInvalid = 535,
63 RecipientAddressRejected = 541,
65 RequestedActionNotTakenMailboxUnavailable = 550,
67 UserNotLocalTryForwarding = 551,
69 ExceededStorageAllocation = 552,
71 MailboxNameNotAllowed = 553,
73 TransactionFailed = 554,
75}
76
77impl StatusCodes {
81 pub fn to_string(&self) -> String {
85 match self {
86 StatusCodes::HelpMessage => "214".to_string(),
87 StatusCodes::SMTPServiceReady => "220".to_string(),
88 StatusCodes::ServiceClosingTransmissionChannel => "221".to_string(),
89 StatusCodes::AuthenticationSuccessful => "235".to_string(),
90 StatusCodes::OK => "250".to_string(),
91 StatusCodes::UserNotLocalWillForward => "251".to_string(),
92 StatusCodes::CannotVerifyUserButWillAcceptMessageAndAttemptDelivery => {
93 "252".to_string()
94 }
95 StatusCodes::StartMailInput => "354".to_string(),
96 StatusCodes::ServiceNotAvailable => "421".to_string(),
97 StatusCodes::RequestedMailActionNotTakenMailboxUnavailable => "450".to_string(),
98 StatusCodes::RequestedActionAbortedLocalErrorInProcessing => "451".to_string(),
99 StatusCodes::InsufficientSystemStorage => "452".to_string(),
100 StatusCodes::ServerUnableToAccommodateParameters => "455".to_string(),
101 StatusCodes::SyntaxError => "500".to_string(),
102 StatusCodes::SyntaxErrorInParametersOrArguments => "501".to_string(),
103 StatusCodes::CommandNotImplemented => "502".to_string(),
104 StatusCodes::BadSequenceOfCommands => "503".to_string(),
105 StatusCodes::CommandParameterNotImplemented => "504".to_string(),
106 StatusCodes::ServerDoesNotAcceptMail => "521".to_string(),
107 StatusCodes::AuthenticationCredetialsInvalid => "535".to_string(),
108 StatusCodes::RecipientAddressRejected => "541".to_string(),
109 StatusCodes::RequestedActionNotTakenMailboxUnavailable => "550".to_string(),
110 StatusCodes::UserNotLocalTryForwarding => "551".to_string(),
111 StatusCodes::ExceededStorageAllocation => "552".to_string(),
112 StatusCodes::MailboxNameNotAllowed => "553".to_string(),
113 StatusCodes::TransactionFailed => "554".to_string(),
114 }
115 }
116}