Skip to content

Package: SMTPSenderFailedException

SMTPSenderFailedException

nameinstructionbranchcomplexitylinemethod
SMTPSenderFailedException(InternetAddress, String, int, String)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getAddress()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getCommand()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getReturnCode()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.smtp;
18:
19: import jakarta.mail.SendFailedException;
20: import jakarta.mail.internet.InternetAddress;
21:
22: /**
23: * This exception is thrown when the message cannot be sent. <p>
24: *
25: * The exception includes the sender's address, which the mail server
26: * rejected.
27: *
28: * @since JavaMail 1.4.4
29: */
30:
31: public class SMTPSenderFailedException extends SendFailedException {
32: protected InternetAddress addr;        // address that failed
33: protected String cmd;                // command issued to server
34: protected int rc;                        // return code from SMTP server
35:
36: private static final long serialVersionUID = 514540454964476947L;
37:
38: /**
39: * Constructs an SMTPSenderFailedException with the specified
40: * address, return code, and error string.
41: *
42: * @param addr        the address that failed
43: * @param cmd        the command that was sent to the SMTP server
44: * @param rc        the SMTP return code indicating the failure
45: * @param err        the error string from the SMTP server
46: */
47: public SMTPSenderFailedException(InternetAddress addr, String cmd, int rc,
48:                                 String err) {
49:         super(err);
50:         this.addr = addr;
51:         this.cmd = cmd;
52:         this.rc = rc;
53: }
54:
55: /**
56: * Return the address that failed.
57: *
58: * @return        the address
59: */
60: public InternetAddress getAddress() {
61:         return addr;
62: }
63:
64: /**
65: * Return the command that failed.
66: *
67: * @return        the command
68: */
69: public String getCommand() {
70:         return cmd;
71: }
72:
73:
74: /**
75: * Return the return code from the SMTP server that indicates the
76: * reason for the failure. See
77: * <A HREF="http://www.ietf.org/rfc/rfc821.txt">RFC 821</A>
78: * for interpretation of the return code.
79: *
80: * @return        the return code
81: */
82: public int getReturnCode() {
83:         return rc;
84: }
85: }