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 ***/ 030 031 public final class SMTPCommand 032 { 033 034 035 public static final int HELO = 0; 036 public static final int MAIL = 1; 037 public static final int RCPT = 2; 038 public static final int DATA = 3; 039 public static final int SEND = 4; 040 public static final int SOML = 5; 041 public static final int SAML = 6; 042 public static final int RSET = 7; 043 public static final int VRFY = 8; 044 public static final int EXPN = 9; 045 public static final int HELP = 10; 046 public static final int NOOP = 11; 047 public static final int TURN = 12; 048 public static final int QUIT = 13; 049 050 /** 051 * The authorization command 052 * @since 3.0 053 */ 054 public static final int AUTH = 14 ; 055 056 /** 057 * The extended hello command 058 * @since 3.0 059 */ 060 public static final int EHLO = 15 ; 061 062 private static final int _NEXT_ = EHLO + 1; // update as necessary when adding new entries 063 064 public static final int HELLO = HELO; 065 public static final int LOGIN = HELO; 066 public static final int MAIL_FROM = MAIL; 067 public static final int RECIPIENT = RCPT; 068 public static final int SEND_MESSAGE_DATA = DATA; 069 public static final int SEND_FROM = SEND; 070 public static final int SEND_OR_MAIL_FROM = SOML; 071 public static final int SEND_AND_MAIL_FROM = SAML; 072 public static final int RESET = RSET; 073 public static final int VERIFY = VRFY; 074 public static final int EXPAND = EXPN; 075 // public static final int HELP = HELP; 076 // public static final int NOOP = NOOP; 077 // public static final int TURN = TURN; 078 // public static final int QUIT = QUIT; 079 public static final int LOGOUT = QUIT; 080 081 // Cannot be instantiated 082 private SMTPCommand() 083 {} 084 085 private static final String[] _commands = { 086 "HELO", "MAIL FROM:", "RCPT TO:", "DATA", "SEND FROM:", "SOML FROM:", 087 "SAML FROM:", "RSET", "VRFY", "EXPN", "HELP", "NOOP", "TURN", "QUIT", 088 "AUTH", "EHLO" 089 }; 090 091 092 static { 093 if (_commands.length != _NEXT_) { 094 throw new RuntimeException("Error in array definition"); 095 } 096 } 097 098 /*** 099 * Retrieve the SMTP protocol command string corresponding to a specified 100 * command code. 101 * <p> 102 * @param command The command code. 103 * @return The SMTP protcol command string corresponding to a specified 104 * command code. 105 ***/ 106 public static final String getCommand(int command) 107 { 108 return _commands[command]; 109 } 110 111 }