Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/breedinginsight/services/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ private void sendAccountSignUpEmail(BiUserEntity user, SignedJWT jwtToken) {
String filledBody = emailTemplate.render();
String subject = "Activate DeltaBreed Account";

log.debug(filledBody);

// Send email
emailUtil.sendEmail(user.getEmail(), subject, filledBody);
}
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/breedinginsight/utilities/email/EmailUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import io.micronaut.context.annotation.Property;
import io.micronaut.http.server.exceptions.HttpServerException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import javax.inject.Singleton;
Expand All @@ -29,6 +30,7 @@
import java.util.Date;
import java.util.Properties;

@Slf4j
@Singleton
public class EmailUtil {

Expand Down Expand Up @@ -66,6 +68,8 @@ protected PasswordAuthentication getPasswordAuthentication() {
public void sendEmail(String toEmail, String subject, String body){
try
{
log.debug("Sending email to: " + toEmail + " from: " + fromEmail + " with subject: " + subject);

Session session = getSmtpHost();
MimeMessage msg = new MimeMessage(session);
//set message headers
Expand All @@ -83,11 +87,16 @@ public void sendEmail(String toEmail, String subject, String body){

msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail, false));
Transport.send(msg);

log.debug("Email sent to: " + toEmail + " from: " + fromEmail + " with subject: " + subject);
}
catch (UnsupportedEncodingException | MessagingException e) {
catch (UnsupportedEncodingException e) {
log.debug("UnsupportedEncodingException " + e.getMessage());
throw new HttpServerException(e.getMessage());
} catch (MessagingException e) {
log.debug("MessagingException " + e.getMessage());
throw new HttpServerException(e.getMessage());
}
}


}
Loading