Skip to contentMethod: getInvalidAddresses()
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 jakarta.mail;
18:
19: /**
20: * This exception is thrown when the message cannot be sent.<p>
21: *
22: * The exception includes those addresses to which the message could not be
23: * sent as well as the valid addresses to which the message was sent and
24: * valid addresses to which the message was not sent.
25: *
26: * @author John Mani
27: * @author Max Spivak
28: * @see jakarta.mail.Transport#send
29: * @see jakarta.mail.Transport#sendMessage
30: * @see jakarta.mail.event.TransportEvent
31: */
32:
33: public class SendFailedException extends MessagingException {
34:
35: /**
36: * The invalid addresses.
37: */
38: transient protected Address[] invalid;
39: /**
40: * Valid addresses to which message was sent.
41: */
42: transient protected Address[] validSent;
43: /**
44: * Valid addresses to which message was not sent.
45: */
46: transient protected Address[] validUnsent;
47:
48: private static final long serialVersionUID = -6457531621682372913L;
49:
50: /**
51: * Constructs a SendFailedException with no detail message.
52: */
53: public SendFailedException() {
54: super();
55: }
56:
57: /**
58: * Constructs a SendFailedException with the specified detail message.
59: *
60: * @param s the detail message
61: */
62: public SendFailedException(String s) {
63: super(s);
64: }
65:
66: /**
67: * Constructs a SendFailedException with the specified
68: * Exception and detail message. The specified exception is chained
69: * to this exception.
70: *
71: * @param s the detail message
72: * @param e the embedded exception
73: * @see #getNextException
74: * @see #setNextException
75: */
76: public SendFailedException(String s, Exception e) {
77: super(s, e);
78: }
79:
80:
81: /**
82: * Constructs a SendFailedException with the specified string
83: * and the specified address objects.
84: *
85: * @param msg the detail message
86: * @param ex the embedded exception
87: * @param validSent valid addresses to which message was sent
88: * @param validUnsent valid addresses to which message was not sent
89: * @param invalid the invalid addresses
90: * @see #getNextException
91: * @see #setNextException
92: */
93: public SendFailedException(String msg, Exception ex, Address[] validSent,
94: Address[] validUnsent, Address[] invalid) {
95: super(msg, ex);
96: this.validSent = validSent;
97: this.validUnsent = validUnsent;
98: this.invalid = invalid;
99: }
100:
101: /**
102: * Return the addresses to which this message was sent succesfully.
103: *
104: * @return Addresses to which the message was sent successfully or null
105: */
106: public Address[] getValidSentAddresses() {
107: return validSent;
108: }
109:
110: /**
111: * Return the addresses that are valid but to which this message
112: * was not sent.
113: *
114: * @return Addresses that are valid but to which the message was
115: * not sent successfully or null
116: */
117: public Address[] getValidUnsentAddresses() {
118: return validUnsent;
119: }
120:
121: /**
122: * Return the addresses to which this message could not be sent.
123: *
124: * @return Addresses to which the message sending failed or null;
125: */
126: public Address[] getInvalidAddresses() {
127: return invalid;
128: }
129: }