    View Javadoc
    1   package org.apache.commons.net.smtp;
    2
    3   /* ====================================================================
    4    * The Apache Software License, Version 1.1
    5    *
    6    * Copyright (c) 2001 The Apache Software Foundation.  All rights
    7    * reserved.
    8    *
    9    * Redistribution and use in source and binary forms, with or without
    10   * modification, are permitted provided that the following conditions
    11   * are met:
    12   *
    13   * 1. Redistributions of source code must retain the above copyright
    14   *    notice, this list of conditions and the following disclaimer.
    15   *
    16   * 2. Redistributions in binary form must reproduce the above copyright
    17   *    notice, this list of conditions and the following disclaimer in
    18   *    the documentation and/or other materials provided with the
    19   *    distribution.
    20   *
    21   * 3. The end-user documentation included with the redistribution,
    22   *    if any, must include the following acknowledgment:
    23   *       "This product includes software developed by the
    24   *        Apache Software Foundation (http://www.apache.org/)."
    25   *    Alternately, this acknowledgment may appear in the software itself,
    26   *    if and wherever such third-party acknowledgments normally appear.
    27   *
    28   * 4. The names "Apache" and "Apache Software Foundation" and
    29   *    "Apache Commons" must not be used to endorse or promote products
    30   *    derived from this software without prior written permission. For
    31   *    written permission, please contact apache@apache.org.
    32   *
    33   * 5. Products derived from this software may not be called "Apache",
    34   *    nor may "Apache" appear in their name, without
    35   *    prior written permission of the Apache Software Foundation.
    36   *
    37   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    38   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    39   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    40   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    41   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    42   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    43   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    44   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    45   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    46   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    47   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    48   * SUCH DAMAGE.
    49   * ====================================================================
    50   *
    51   * This software consists of voluntary contributions made by many
    52   * individuals on behalf of the Apache Software Foundation.  For more
    53   * information on the Apache Software Foundation, please see
    54   * <http://www.apache.org/>;.
    55   */
    56
    57  /****
    58   * SMTPReply stores a set of constants for SMTP reply codes.  To interpret
    59   * the meaning of the codes, familiarity with RFC 821 is assumed.
    60   * The mnemonic constant names are transcriptions from the code descriptions
    61   * of RFC 821.  For those who think in terms of the actual reply code values,
    62   * a set of CODE_NUM constants are provided where NUM is the numerical value
    63   * of the code.
    64   * <p>
    65   * <p>
    66   * @author Daniel F. Savarese
    67   ***/
    68
    69  public final class SMTPReply
    70  {
    71
    72      public static final int CODE_211 = 211;
    73      public static final int CODE_214 = 214;
    74      public static final int CODE_215 = 215;
    75      public static final int CODE_220 = 220;
    76      public static final int CODE_221 = 221;
    77      public static final int CODE_250 = 250;
    78      public static final int CODE_251 = 251;
    79      public static final int CODE_354 = 354;
    80      public static final int CODE_421 = 421;
    81      public static final int CODE_450 = 450;
    82      public static final int CODE_451 = 451;
    83      public static final int CODE_452 = 452;
    84      public static final int CODE_500 = 500;
    85      public static final int CODE_501 = 501;
    86      public static final int CODE_502 = 502;
    87      public static final int CODE_503 = 503;
    88      public static final int CODE_504 = 504;
    89      public static final int CODE_550 = 550;
    90      public static final int CODE_551 = 551;
    91      public static final int CODE_552 = 552;
    92      public static final int CODE_553 = 553;
    93      public static final int CODE_554 = 554;
    94
    95      public static final int SYSTEM_STATUS = CODE_211;
    96      public static final int HELP_MESSAGE = CODE_214;
    97      public static final int SERVICE_READY = CODE_220;
    98      public static final int SERVICE_CLOSING_TRANSMISSION_CHANNEL = CODE_221;
    99      public static final int ACTION_OK = CODE_250;
    100     public static final int USER_NOT_LOCAL_WILL_FORWARD = CODE_251;
    101     public static final int START_MAIL_INPUT = CODE_354;
    102     public static final int SERVICE_NOT_AVAILABLE = CODE_421;
    103     public static final int ACTION_NOT_TAKEN = CODE_450;
    104     public static final int ACTION_ABORTED = CODE_451;
    105     public static final int INSUFFICIENT_STORAGE = CODE_452;
    106     public static final int UNRECOGNIZED_COMMAND = CODE_500;
    107     public static final int SYNTAX_ERROR_IN_ARGUMENTS = CODE_501;
    108     public static final int COMMAND_NOT_IMPLEMENTED = CODE_502;
    109     public static final int BAD_COMMAND_SEQUENCE = CODE_503;
    110     public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = CODE_504;
    111     public static final int MAILBOX_UNAVAILABLE = CODE_550;
    112     public static final int USER_NOT_LOCAL = CODE_551;
    113     public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552;
    114     public static final int MAILBOX_NAME_NOT_ALLOWED = CODE_553;
    115     public static final int TRANSACTION_FAILED = CODE_554;
    116
    117     // Cannot be instantiated
    118     private SMTPReply()
    119     {}
    120
    121     /****
    122      * Determine if a reply code is a positive preliminary response.  All
    123      * codes beginning with a 1 are positive preliminary responses.
    124      * Postitive preliminary responses are used to indicate tentative success.
    125      * No further commands can be issued to the SMTP server after a positive
    126      * preliminary response until a follow up response is received from the
    127      * server.
    128      * <p>
    129      * <b> Note: </b> <em> No SMTP commands defined in RFC 822 provide this
    130      * type of reply. </em>
    131      * <p>
    132      * @param reply  The reply code to test.
    133      * @return True if a reply code is a postive preliminary response, false
    134      *         if not.
    135      ***/
    136     public static boolean isPositivePreliminary(int reply)
    137     {
    138         return (reply >= 100 && reply < 200);
    139     }
    140
    141     /****
    142      * Determine if a reply code is a positive completion response.  All
    143      * codes beginning with a 2 are positive completion responses.
    144      * The SMTP server will send a positive completion response on the final
    145      * successful completion of a command.
    146      * <p>
    147      * @param reply  The reply code to test.
    148      * @return True if a reply code is a postive completion response, false
    149      *         if not.
    150      ***/
    151     public static boolean isPositiveCompletion(int reply)
    152     {
    153         return (reply >= 200 && reply < 300);
    154     }
    155
    156     /****
    157      * Determine if a reply code is a positive intermediate response.  All
    158      * codes beginning with a 3 are positive intermediate responses.
    159      * The SMTP server will send a positive intermediate response on the
    160      * successful completion of one part of a multi-part sequence of
    161      * commands.  For example, after a successful DATA command, a positive
    162      * intermediate response will be sent to indicate that the server is
    163      * ready to receive the message data.
    164      * <p>
    165      * @param reply  The reply code to test.
    166      * @return True if a reply code is a postive intermediate response, false
    167      *         if not.
    168      ***/
    169     public static boolean isPositiveIntermediate(int reply)
    170     {
    171         return (reply >= 300 && reply < 400);
    172     }
    173
    174     /****
    175      * Determine if a reply code is a negative transient response.  All
    176      * codes beginning with a 4 are negative transient responses.
    177      * The SMTP server will send a negative transient response on the
    178      * failure of a command that can be reattempted with success.
    179      * <p>
    180      * @param reply  The reply code to test.
    181      * @return True if a reply code is a negative transient response, false
    182      *         if not.
    183      ***/
    184     public static boolean isNegativeTransient(int reply)
    185     {
    186         return (reply >= 400 && reply < 500);
    187     }
    188
    189     /****
    190      * Determine if a reply code is a negative permanent response.  All
    191      * codes beginning with a 5 are negative permanent responses.
    192      * The SMTP server will send a negative permanent response on the
    193      * failure of a command that cannot be reattempted with success.
    194      * <p>
    195      * @param reply  The reply code to test.
    196      * @return True if a reply code is a negative permanent response, false
    197      *         if not.
    198      ***/
    199     public static boolean isNegativePermanent(int reply)
    200     {
    201         return (reply >= 500 && reply < 600);
    202     }
    203
    204 }

This page was automatically generated by Maven