diff --git a/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java index a4db326..30d7301 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java @@ -580,7 +580,12 @@ public class EmailUtilsImpl implements EmailUtils { "If you have any questions, write to 'helpdesk@openaire.eu'."; message = createUserMail(message, authentication); - this.sendMail(issuer, subject, message); + Collection emailTo = new HashSet<>(); + if (repository.getRegisteredby() != null) { + emailTo.add(repository.getRegisteredby()); + } + emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail()); + this.sendMail(emailTo, subject, message); } catch (Exception e) { logger.error("Error while sending validation submission notification email to user: " + issuer, e); @@ -660,7 +665,12 @@ public class EmailUtilsImpl implements EmailUtils { "If you have any questions, write to 'helpdesk@openaire.eu'."; message = createUserMail(message, authentication); - this.sendMail(repository.getRegisteredby(), subject, message); + Collection emailTo = new HashSet<>(); + if (repository.getRegisteredby() != null) { + emailTo.add(repository.getRegisteredby()); + } + emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail()); + this.sendMail(emailTo, subject, message); } catch (Exception e) { logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e); @@ -720,7 +730,12 @@ public class EmailUtilsImpl implements EmailUtils { "If you have any questions, write to 'helpdesk@openaire.eu'."; message = createUserMail(message, authentication); - this.sendMail(repository.getRegisteredby(), subject, message); + Collection emailTo = new HashSet<>(); + if (repository.getRegisteredby() != null) { + emailTo.add(repository.getRegisteredby()); + } + emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail()); + this.sendMail(emailTo, subject, message); } catch (Exception e) { logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);