1 module smtp.reply; 2 3 import std.conv; 4 5 /++ 6 SMTP server reply codes, RFC 2921, April 2001 7 +/ 8 enum SmtpReplyCode : uint { 9 HELP_STATUS = 211, // Information reply 10 HELP = 214, // Information reply 11 12 READY = 220, // After connection is established 13 QUIT = 221, // After connected aborted 14 AUTH_SUCCESS = 235, // Authentication succeeded 15 OK = 250, // Transaction success 16 FORWARD = 251, // Non-local user, message is forwarded 17 VRFY_FAIL = 252, // Verification failed (still attempt to deliver) 18 19 AUTH_CONTINUE = 334, // Answer to AUTH <method> prompting to send auth data 20 DATA_START = 354, // Server starts to accept mail data 21 22 NA = 421, // Not Available. Shutdown must follow after this reply 23 NEED_PASSWORD = 435, // Password transition is needed 24 BUSY = 450, // Mail action failed 25 ABORTED = 451, // Action aborted (internal server error) 26 STORAGE = 452, // Not enough system storage on server 27 TLS = 454, // TLS unavailable | Temporary Auth fail 28 29 SYNTAX = 500, // Command syntax error | Too long auth command line 30 SYNTAX_PARAM = 501, // Command parameter syntax error 31 NI = 502, // Command not implemented 32 BAD_SEQUENCE = 503, // This command breaks specified allowed sequences 33 NI_PARAM = 504, // Command parameter not implemented 34 35 AUTH_REQUIRED = 530, // Authentication required 36 AUTH_TOO_WEAK = 534, // Need stronger authentication type 37 AUTH_CRED = 535, // Wrong authentication credentials 38 AUTH_ENCRYPTION = 538, // Encryption reqiured for current authentication type 39 40 MAILBOX = 550, // Mailbox is not found (for different reasons) 41 TRY_FORWARD = 551, // Non-local user, forwarding is needed 42 MAILBOX_STORAGE = 552, // Storage for mailbox exceeded 43 MAILBOX_NAME = 553, // Unallowed name for the mailbox 44 FAIL = 554 // Transaction fail 45 }; 46 47 /++ 48 SMTP Reply 49 +/ 50 struct SmtpReply { 51 bool success; 52 uint code; 53 string message; 54 55 string toString() { 56 return to!string(code) ~ message; 57 } 58 }; 59 60 unittest { 61 // Testing SmtpReply toString converesion 62 auto reply = SmtpReply(true, 220, " Hello, ready to work\r\n"); 63 assert(reply.toString == "220 Hello, ready to work\r\n"); 64 }