Hi Pavlo, many years ago (15?) ago I build some email service where it was very useful to avoid sending real emails to real customers during tests or write the emails to disk.
My entry point was 4 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1484> /** 1485 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1485> * Sends the email. Internally we build a MimeMessage 1486 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1486> * which is afterwards sent to the SMTP server. 1487 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1487> * 1488 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1488> * @return the message id of the underlying MimeMessage 1489 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1489> * @throws IllegalStateException if the MimeMessage was already built, ie {@link #buildMimeMessage()} 1490 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1490> * was already called 1491 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1491> * @throws EmailException the sending failed 1492 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1492> */ 1493 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1493> public String send() throws EmailException 1494 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1494> { 1495 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1495> this.buildMimeMessage(); 1496 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1496> return this.sendMimeMessage(); 1497 <https://commons.apache.org/proper/commons-email/xref/org/apache/commons/mail/Email.html#L1497> } So there is a clear distinction between building the MimeMessage and sending it - so this might help Thanks in advance, Siegfried Goeschl > On 27 Aug 2019, at 15:34, sebb <[email protected]> wrote: > > On Tue, 27 Aug 2019 at 12:02, Pavlo Polishchuk <[email protected]> wrote: >> >> Good day, >> Is there a way to unset CC/BCC through "org.apache.commons.mail.Email" ? >> >> I tried "email.setCC" with empty collection but there is a check for >> null/empty collection inside. >> Also, tried to "email.getMimeMessage().setRecipients(...)" but this fails >> with NPE since MimeMessage is not build at that time. >> >> Do I miss something? > > The underlying list is accessible as a protected field and via code of the > form: > > List list = email.getBccAddresses(); > > so it's easy enough to clear the list if required. > > An alternative is not to set the list in the first place ... > >> Thanks in advance! >> >> -- >> Best regards, >> Paul > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >
