001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.net.smtp;
019
020 /***
021 * SMTPCommand stores a set of constants for SMTP command codes. To interpret
022 * the meaning of the codes, familiarity with RFC 821 is assumed.
023 * The mnemonic constant names are transcriptions from the code descriptions
024 * of RFC 821. For those who think in terms of the actual SMTP commands,
025 * a set of constants such as {@link #HELO HELO } are provided
026 * where the constant name is the same as the SMTP command.
027 * <p>
028 * <p>
029 * @author Daniel F. Savarese
030 ***/
031
032 public final class SMTPCommand
033 {
034
035
036 public static final int HELO = 0;
037 public static final int MAIL = 1;
038 public static final int RCPT = 2;
039 public static final int DATA = 3;
040 public static final int SEND = 4;
041 public static final int SOML = 5;
042 public static final int SAML = 6;
043 public static final int RSET = 7;
044 public static final int VRFY = 8;
045 public static final int EXPN = 9;
046 public static final int HELP = 10;
047 public static final int NOOP = 11;
048 public static final int TURN = 12;
049 public static final int QUIT = 13;
050
051 public static final int HELLO = HELO;
052 public static final int LOGIN = HELO;
053 public static final int MAIL_FROM = MAIL;
054 public static final int RECIPIENT = RCPT;
055 public static final int SEND_MESSAGE_DATA = DATA;
056 public static final int SEND_FROM = SEND;
057 public static final int SEND_OR_MAIL_FROM = SOML;
058 public static final int SEND_AND_MAIL_FROM = SAML;
059 public static final int RESET = RSET;
060 public static final int VERIFY = VRFY;
061 public static final int EXPAND = EXPN;
062 // public static final int HELP = HELP;
063 // public static final int NOOP = NOOP;
064 // public static final int TURN = TURN;
065 // public static final int QUIT = QUIT;
066 public static final int LOGOUT = QUIT;
067
068 // Cannot be instantiated
069 private SMTPCommand()
070 {}
071
072 static final String[] _commands = {
073 "HELO", "MAIL FROM:", "RCPT TO:", "DATA", "SEND FROM:", "SOML FROM:",
074 "SAML FROM:", "RSET", "VRFY", "EXPN", "HELP", "NOOP", "TURN", "QUIT"
075 };
076
077
078 /***
079 * Retrieve the SMTP protocol command string corresponding to a specified
080 * command code.
081 * <p>
082 * @param command The command code.
083 * @return The SMTP protcol command string corresponding to a specified
084 * command code.
085 ***/
086 public static final String getCommand(int command)
087 {
088 return _commands[command];
089 }
090
091 }