1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.net.smtp; 19 20 /*** 21 * SMTPReply stores a set of constants for SMTP reply codes. To interpret 22 * the meaning of the codes, familiarity with RFC 821 is assumed. 23 * The mnemonic constant names are transcriptions from the code descriptions 24 * of RFC 821. 25 ***/ 26 27 public final class SMTPReply 28 { 29 30 public static final int SYSTEM_STATUS = 211; 31 public static final int HELP_MESSAGE = 214; 32 public static final int SERVICE_READY = 220; 33 public static final int SERVICE_CLOSING_TRANSMISSION_CHANNEL = 221; 34 public static final int ACTION_OK = 250; 35 public static final int USER_NOT_LOCAL_WILL_FORWARD = 251; 36 public static final int START_MAIL_INPUT = 354; 37 public static final int SERVICE_NOT_AVAILABLE = 421; 38 public static final int ACTION_NOT_TAKEN = 450; 39 public static final int ACTION_ABORTED = 451; 40 public static final int INSUFFICIENT_STORAGE = 452; 41 public static final int UNRECOGNIZED_COMMAND = 500; 42 public static final int SYNTAX_ERROR_IN_ARGUMENTS = 501; 43 public static final int COMMAND_NOT_IMPLEMENTED = 502; 44 public static final int BAD_COMMAND_SEQUENCE = 503; 45 public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = 504; 46 public static final int MAILBOX_UNAVAILABLE = 550; 47 public static final int USER_NOT_LOCAL = 551; 48 public static final int STORAGE_ALLOCATION_EXCEEDED = 552; 49 public static final int MAILBOX_NAME_NOT_ALLOWED = 553; 50 public static final int TRANSACTION_FAILED = 554; 51 52 // Cannot be instantiated 53 private SMTPReply() 54 {} 55 56 /*** 57 * Determine if a reply code is a positive preliminary response. All 58 * codes beginning with a 1 are positive preliminary responses. 59 * Postitive preliminary responses are used to indicate tentative success. 60 * No further commands can be issued to the SMTP server after a positive 61 * preliminary response until a follow up response is received from the 62 * server. 63 * <p> 64 * <b> Note: </b> <em> No SMTP commands defined in RFC 822 provide this 65 * type of reply. </em> 66 * <p> 67 * @param reply The reply code to test. 68 * @return True if a reply code is a postive preliminary response, false 69 * if not. 70 ***/ 71 public static boolean isPositivePreliminary(int reply) 72 { 73 return (reply >= 100 && reply < 200); 74 } 75 76 /*** 77 * Determine if a reply code is a positive completion response. All 78 * codes beginning with a 2 are positive completion responses. 79 * The SMTP server will send a positive completion response on the final 80 * successful completion of a command. 81 * <p> 82 * @param reply The reply code to test. 83 * @return True if a reply code is a postive completion response, false 84 * if not. 85 ***/ 86 public static boolean isPositiveCompletion(int reply) 87 { 88 return (reply >= 200 && reply < 300); 89 } 90 91 /*** 92 * Determine if a reply code is a positive intermediate response. All 93 * codes beginning with a 3 are positive intermediate responses. 94 * The SMTP server will send a positive intermediate response on the 95 * successful completion of one part of a multi-part sequence of 96 * commands. For example, after a successful DATA command, a positive 97 * intermediate response will be sent to indicate that the server is 98 * ready to receive the message data. 99 * <p> 100 * @param reply The reply code to test. 101 * @return True if a reply code is a postive intermediate response, false 102 * if not. 103 ***/ 104 public static boolean isPositiveIntermediate(int reply) 105 { 106 return (reply >= 300 && reply < 400); 107 } 108 109 /*** 110 * Determine if a reply code is a negative transient response. All 111 * codes beginning with a 4 are negative transient responses. 112 * The SMTP server will send a negative transient response on the 113 * failure of a command that can be reattempted with success. 114 * <p> 115 * @param reply The reply code to test. 116 * @return True if a reply code is a negative transient response, false 117 * if not. 118 ***/ 119 public static boolean isNegativeTransient(int reply) 120 { 121 return (reply >= 400 && reply < 500); 122 } 123 124 /*** 125 * Determine if a reply code is a negative permanent response. All 126 * codes beginning with a 5 are negative permanent responses. 127 * The SMTP server will send a negative permanent response on the 128 * failure of a command that cannot be reattempted with success. 129 * <p> 130 * @param reply The reply code to test. 131 * @return True if a reply code is a negative permanent response, false 132 * if not. 133 ***/ 134 public static boolean isNegativePermanent(int reply) 135 { 136 return (reply >= 500 && reply < 600); 137 } 138 139 }