cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

Email is not sent to cc and bcc addresses #3190

Closed DartVerder closed 3 years ago

DartVerder commented 3 years ago

https://www.cuba-platform.ru/discuss/t/emailinfo-setcc-setbcc-parametr-ustanavlivaetsya-no-soobshheniya-ne-otpravlyayutsya/5674

Environment

Description of the bug or enhancement

  1. specify properties in app.properties file:
    cuba.email.smtpHost
    cuba.email.smtpPort
    cuba.email.smtpStarttlsEnable
    cuba.email.smtpAuthRequired
    cuba.email.smtpUser
    cuba.email.smtpPassword
    cuba.schedulingActive
  2. create new screen and add button to the screen
  3. add button id and on-click action like (replacing email addresses):
    @Subscribe("send")
    public void onAsyncClick(Button.ClickEvent event) throws EmailException {
        EmailInfo emailInfo = EmailInfoBuilder.create()
                .setAddresses("mail@maii.ru")
                .setBcc("bccmail@mail.ru")
                .setCc("ccmail@mail.ru")
                .setFrom("test@mail.ru")
                .setCaption("test caption").setBody("new message")
                .build();
        emailService.sendEmail(emailInfo);
    }
  4. run application -> open created screen -> click on button
  5. Open Administration -> Email History and make sure that the message has been sent

ER: email was sent to the all addresses, include cc, bcc AR: email was sent only to the addresses, that were in setAddresses("mail@maii.ru")

artemglinov commented 3 years ago

There are two ways of sending emails, depending on the EmailInfo#sendInOneMessage flag value. If it is set to false (which is a default value), multiple messages are sent to addresses listed in EmailInfo#addresses field and EmailInfo#cc, EmailInfo#bcc fields are ignored. If it is set to true, only one email is sent to all the recipients; that means the use of CC/BCC fields is reasonable in this case. To solve the problem, one should either call EmailInfoBuilder#setSendInOneMessage(true) in the builder chain, or just add CC/BCC addresses to EmailInfo#addresses list (by an appropriate setter). More info on this topic is presented in a Javadoc comment. Nevertheless, to clarify this in more detail, additional Javadoc comments on EmailInfo#cc and EmailInfo#bcc are required.

artemglinov commented 3 years ago

Won't fix. Javadoc comments were added.