Index: src/main/groovy/com/lemans/pricecalc/services/helper/EmailService.groovy =================================================================== diff -u -rb6a4991a63e8f44e214e4815d4b92a30d925bae1 -rda6fd1701639b11ae4d571f27a0be09e9fd14e8c --- src/main/groovy/com/lemans/pricecalc/services/helper/EmailService.groovy (.../EmailService.groovy) (revision b6a4991a63e8f44e214e4815d4b92a30d925bae1) +++ src/main/groovy/com/lemans/pricecalc/services/helper/EmailService.groovy (.../EmailService.groovy) (revision da6fd1701639b11ae4d571f27a0be09e9fd14e8c) @@ -5,32 +5,31 @@ import groovy.text.Template import groovy.text.markup.MarkupTemplateEngine import groovy.text.markup.TemplateConfiguration -import groovy.util.logging.Slf4j import org.springframework.beans.factory.annotation.Autowired -import org.springframework.mail.javamail.JavaMailSenderImpl +import org.springframework.mail.MailSender import org.springframework.stereotype.Service + import javax.mail.internet.InternetAddress import javax.mail.internet.MimeMessage @Service -@Slf4j class EmailService extends LemansService { @Autowired - JavaMailSenderImpl javaMailSender + MailSender mailSender @Autowired String emailSubPrefix - static final String NO_REPLY_FROM = 'HelpDesk' + static final String NO_REPLY_FROM = 'HelpDesk' private static final String PENDING_BUYER_REVIEWS = '''SELECT partNumber FROM calcPro.vwCatalogPart WITH(NOLOCK) WHERE catalogId = :catalogId AND dateDeleted IS NULL - AND statusCodeId IN (39600, 39608) + AND statusCodeId IN (39600) AND vendorId = :vendorId''' private static final String PENDING_MANAGER_APPROVALS = '''SELECT @@ -39,7 +38,7 @@ CalcPro.vwCatalogPart WITH(NOLOCK) WHERE catalogId = :catalogId AND dateDeleted IS NULL - AND statusCodeId IN (39600, 39608, 39601, 39609) + AND statusCodeId IN (39600, 39601, 39609) AND vendorId = :vendorId''' private static final String REJECTION_REVIEWS = '''SELECT @@ -74,7 +73,6 @@ to: [vendorInfo?.buyerGlobalId?.toString().replaceAll('\\s', '') + '@parts-unltd.com'], subject: empty(emailSubPrefix)? 'Pending Buyer review(s)' : emailSubPrefix + ' ' + 'Pending Buyer review(s)' ] - log.debug('body for email ' + body) sendEmail('buyerAlertEmail', body) } } @@ -97,7 +95,7 @@ List buyers = [] if (vendorInfo) { vendorInfo*.buyerGlobalId?.each { String buyerGlobalId -> - buyers << buyerGlobalId.replaceAll('\\s', '') + '@parts-unltd.com' + buyers << buyerGlobalId.replaceAll('\\s', '') + '@parts-unltd.com' } Map body = [ @@ -110,22 +108,20 @@ } void sendEmail(String viewName, Map body) { - log.debug("sending email to ${body.to} with view ${viewName}") Writer writer = new StringWriter() String tmpl = getEmailTemplate(viewName) TemplateConfiguration config = new TemplateConfiguration() MarkupTemplateEngine engine = new MarkupTemplateEngine(config) Template template = engine.createTemplate(tmpl) Writable output = template.make(body) output.writeTo(writer) - MimeMessage mimeMessage = javaMailSender.createMimeMessage() + + MimeMessage mimeMessage = mailSender.createMimeMessage() body.to.each { mimeMessage.addRecipient(MimeMessage.RecipientType.TO, new InternetAddress(it)) } mimeMessage.from = new InternetAddress(NO_REPLY_FROM) mimeMessage.subject = body.subject mimeMessage.setContent writer.toString(), 'text/html' - javaMailSender.send(mimeMessage) - log.debug("email sent to ${body.to}") - + mailSender.send(mimeMessage) } private String getEmailTemplate(String viewName) { Index: src/main/resources/application.groovy =================================================================== diff -u -r43a6c0301aeebd5bc01b49c7c553ae512e110c09 -rda6fd1701639b11ae4d571f27a0be09e9fd14e8c --- src/main/resources/application.groovy (.../application.groovy) (revision 43a6c0301aeebd5bc01b49c7c553ae512e110c09) +++ src/main/resources/application.groovy (.../application.groovy) (revision da6fd1701639b11ae4d571f27a0be09e9fd14e8c) @@ -3,7 +3,7 @@ if (Env.getCurrent() == Env.PRODUCTION) { spring.datasource.'jndi-name'='java:comp/env/jdbc/CalcPro' } else { - spring.datasource.url='jdbc:sqlserver://stg-dbprod02vm;databaseName=PartsSource_DS' + spring.datasource.url='jdbc:sqlserver://stg-dbprod06vm;databaseName=PartsSource_DS' spring.datasource.username='Calcpro_user' spring.datasource.password='StgPassword1' } Index: src/main/resources/resources.groovy =================================================================== diff -u -r5547f173354bb14b3476f4ab53b5a89f70a3e5e7 -rda6fd1701639b11ae4d571f27a0be09e9fd14e8c --- src/main/resources/resources.groovy (.../resources.groovy) (revision 5547f173354bb14b3476f4ab53b5a89f70a3e5e7) +++ src/main/resources/resources.groovy (.../resources.groovy) (revision da6fd1701639b11ae4d571f27a0be09e9fd14e8c) @@ -23,15 +23,6 @@ mfFileDropLocation(org.springframework.jndi.JndiObjectFactoryBean) { jndiName = 'java:comp/env/mfFileDropLocation' } - - emailHost(String, 'smtp.office365.com') - emailUserName(String, 'calcpro@parts-unltd.com') - //calcProMailSecurity(String, 'VNb^tE1x05ui1HekyQdh') - - calcProMailSecurity(org.springframework.jndi.JndiObjectFactoryBean) { - jndiName = 'java:comp/env/calcProMailSecurity' - } - emailToggle(org.springframework.jndi.JndiObjectFactoryBean) { jndiName = 'java:comp/env/emailToggle' } @@ -50,9 +41,14 @@ temporaryDocumentPath(org.springframework.jndi.JndiObjectFactoryBean) { jndiName = 'java:comp/env/temporaryDocumentPath' } - calcProMailSecurity(org.springframework.jndi.JndiObjectFactoryBean) { - jndiName = 'java:comp/env/calcProMailSecurity' + servicesMailSecurityUsername(org.springframework.jndi.JndiObjectFactoryBean) { + jndiName = 'java:comp/env/servicesMailSecurityUsername' } + servicesMailSecurityPassword(org.springframework.jndi.JndiObjectFactoryBean) { + jndiName = 'java:comp/env/servicesMailSecurityPassword' + } + emailHost(String, 'smtp.office365.com') + } else { authServiceContext(String, 'http://services3.dev.lemanscorp.com/auth-service/verifyRequest') widenCalcApi(String, 'https://edge-alpha.stage.yden.us/api/calcs') @@ -79,8 +75,8 @@ mailSender(JavaMailSenderImpl) { host = ref('emailHost') port = 587 - username = ref('emailUserName') - password = ref('calcProMailSecurity') + username = ref('servicesMailSecurityUsername') + password = ref('servicesMailSecurityPassword') javaMailProperties = [ 'mail.smtp.auth' : 'true', 'mail.smtp.starttls.enable': 'true',