Search in sources :

Example 6 with EmailTarget

use of com.synopsys.integration.alert.service.email.EmailTarget in project hub-alert by blackducksoftware.

the class UpdateEmailService method handleSend.

private void handleSend(Properties javamailProperties, String smtpFrom, String smtpHost, int smtpPort, boolean smtpAuth, String smtpUsername, String smtpPassword, Map<String, Object> templateFields, String emailAddress) throws AlertException {
    try {
        String alertLogo = alertProperties.createSynopsysLogoPath();
        Map<String, String> contentIdsToFilePaths = new HashMap<>();
        emailMessagingService.addTemplateImage(templateFields, contentIdsToFilePaths, EmailPropertyKeys.EMAIL_LOGO_IMAGE.getPropertyKey(), alertLogo);
        EmailTarget passwordResetEmail = new EmailTarget(emailAddress, TEMPLATE_NAME, templateFields, contentIdsToFilePaths);
        emailMessagingService.sendEmailMessage(javamailProperties, smtpFrom, smtpHost, smtpPort, smtpAuth, smtpUsername, smtpPassword, passwordResetEmail);
    } catch (Exception genericException) {
        throw new AlertException("Problem sending version update email. " + StringUtils.defaultIfBlank(genericException.getMessage(), StringUtils.EMPTY), genericException);
    }
}
Also used : HashMap(java.util.HashMap) EmailTarget(com.synopsys.integration.alert.service.email.EmailTarget) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Aggregations

EmailTarget (com.synopsys.integration.alert.service.email.EmailTarget)6 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)4 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)3 SmtpConfig (com.synopsys.integration.alert.service.email.SmtpConfig)3 EmailChannelMessageModel (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessageModel)2 AddressException (javax.mail.internet.AddressException)2 InternetAddress (javax.mail.internet.InternetAddress)2 Test (org.junit.jupiter.api.Test)2 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)1 EmailAttachmentFormat (com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFormat)1 ValidatedEmailAddresses (com.synopsys.integration.alert.channel.email.distribution.address.ValidatedEmailAddresses)1 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)1 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)1 EmailJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.EmailJobDetailsModel)1 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)1 SmtpConfigBuilder (com.synopsys.integration.alert.service.email.SmtpConfigBuilder)1 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1