001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Copyright 2019-2021 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.types;
028
029
030
031import java.util.List;
032import java.util.Map;
033import java.util.Set;
034
035import javax.mail.MessagingException;
036
037import com.unboundid.util.NotExtensible;
038import com.unboundid.util.ThreadSafety;
039import com.unboundid.util.ThreadSafetyLevel;
040
041
042
043/**
044 * This interface defines a set of methods that may be used to interact with a
045 * multi-part email message, which may include either or both a plain-text or
046 * HTML-formatted body, and may optionally include attachments.
047 */
048@NotExtensible()
049@ThreadSafety(level= ThreadSafetyLevel.INTERFACE_NOT_THREADSAFE)
050public interface EMailMessage
051{
052  /**
053   * Retrieves the sender address for this email message.
054   *
055   * @return  The sender address for this email message.
056   */
057  String getSenderAddress();
058
059
060
061  /**
062   * Retrieves the reply-to address for this email message, if defined.
063   *
064   * @return  The reply-to address for this email message, or {@code null} if
065   *          none is defined.
066   */
067  String getReplyToAddress();
068
069
070
071  /**
072   * Retrieves the set of "to" recipients for this email message.
073   *
074   * @return  The set of "to" recipients for this email message, or an empty set
075   *          if there are none.
076   */
077  Set<String> getToAddresses();
078
079
080
081  /**
082   * Retrieves the set of "cc" recipients for this email message.
083   *
084   * @return  The set of "cc" recipients for this email message, or an empty set
085   *          if there are none.
086   */
087  Set<String> getCCAddresses();
088
089
090
091  /**
092   * Retrieves the set of "bcc" recipients for this email message.
093   *
094   * @return  The set of "bcc" recipients for this email message, or an empty
095   *          set if there are none.
096   */
097  Set<String> getBCCAddresses();
098
099
100
101  /**
102   * Retrieves the subject for this email message.
103   *
104   * @return  The subject for this email message.
105   */
106  String getSubject();
107
108
109
110  /**
111   * Retrieves the plain-text part for this email message, if defined.
112   *
113   * @return  The plain-text part for this email message, or {@code null} if
114   *          none is defined.
115   */
116  String getPlainTextPart();
117
118
119
120  /**
121   * Retrieves the HTML-formatted part for this email message, if defined.
122   *
123   * @return  The HTML-formatted part for this email message, or {@code null} if
124   *          none is defined.
125   */
126  String getHTMLPart();
127
128
129
130  /**
131   * Retrieves a map of the custom headers that should be included in the
132   * email message.
133   *
134   * @return  A map of the custom headers that should be included in the email
135   *          message.
136   */
137  Map<String,List<String>> getCustomHeaders();
138
139
140
141  /**
142   * Retrieves the list of attachments for this email message.
143   *
144   * @return  The list of attachments for this email message, or an empty list
145   *          if there are none.
146   */
147  List<EMailAttachment> getAttachments();
148
149
150
151  /**
152   * Attempts to send this message using the server's default SMTP connection
153   * pool.
154   *
155   * @throws  MessagingException  If a problem is encountered while trying to
156   *                              send the message.
157   */
158  void send()
159       throws MessagingException;
160
161
162
163  /**
164   * Retrieves a string representation for this email message.
165   *
166   * @return  A string representation for this email message.
167   */
168  @Override()
169  String toString();
170}