001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.net.mail;
020
021import java.util.Map;
022
023import lucee.commons.collection.MapFactory;
024
025public final class SMTPExceptionImpl extends SMTPException {
026    
027    private static Map<String, String> codes=MapFactory.<String,String>getConcurrentMap();
028    
029    static {
030        codes.put("211","System status, or system help reply");
031        codes.put("214"," Help message (Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user)");
032        codes.put("220","Service ready");
033        codes.put("221","Service closing transmission channel");
034        codes.put("250","Requested mail action okay, completed");
035        codes.put("251","User not local; will forward to");
036        codes.put("354","Start mail input; end with .");
037        codes.put("421","Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down) ");
038        codes.put("450","Requested mail action not taken: mailbox unavailable (E.g., mailbox busy)");
039        codes.put("451","Requested action aborted: local error in processing");
040        codes.put("452","Requested action not taken: insufficient system storage");
041        codes.put("500","Syntax error, command unrecognized (This may include errors such as command line too long)");
042        codes.put("501","Syntax error in parameters or arguments");
043        codes.put("502","Command not implemented");
044        codes.put("503","Bad sequence of commands");
045        codes.put("504","Command parameter not implemented");
046        codes.put("550","Requested action not taken: mailbox unavailable (E.g., mailbox not found, no access)");
047        codes.put("551","User not local; please try");
048        codes.put("552","Requested mail action aborted: exceeded storage allocation");
049        codes.put("553","Requested action not taken: mailbox name not allowed (E.g., mailbox syntax incorrect) ");
050        codes.put("554","Transaction failed (Or, in the case of a connection-opening response, \"No SMTP service here\")");
051        codes.put("252","Cannot VRFY user, but will accept message and attempt delivery");
052    }
053    
054    public SMTPExceptionImpl(String message) {
055        super(message);
056    }
057    public SMTPExceptionImpl(int code) {
058        this(doMessage(code));
059    }
060    private static String doMessage(int code) {
061        String message=codes.get(String.valueOf(code));
062        if(message==null) message="SMTP Code "+code;
063        else message=code+" - "+message;
064        return message;
065    }
066}