Index: src/main/groovy/com/lemans/pricecalc/services/helper/EmailService.groovy =================================================================== diff -u -rb98d389f4cb1efcb42077efa7d175caf665bb0e3 -rf2ab66ed08129b3951225077ae3a5d291166b73b --- src/main/groovy/com/lemans/pricecalc/services/helper/EmailService.groovy (.../EmailService.groovy) (revision b98d389f4cb1efcb42077efa7d175caf665bb0e3) +++ src/main/groovy/com/lemans/pricecalc/services/helper/EmailService.groovy (.../EmailService.groovy) (revision f2ab66ed08129b3951225077ae3a5d291166b73b) @@ -5,24 +5,23 @@ 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 @@ -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 -rf2ab66ed08129b3951225077ae3a5d291166b73b --- src/main/resources/application.groovy (.../application.groovy) (revision 43a6c0301aeebd5bc01b49c7c553ae512e110c09) +++ src/main/resources/application.groovy (.../application.groovy) (revision f2ab66ed08129b3951225077ae3a5d291166b73b) @@ -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 -r5399ca731fde0781d5e71e3099bcde519fc16932 -rf2ab66ed08129b3951225077ae3a5d291166b73b --- src/main/resources/resources.groovy (.../resources.groovy) (revision 5399ca731fde0781d5e71e3099bcde519fc16932) +++ src/main/resources/resources.groovy (.../resources.groovy) (revision f2ab66ed08129b3951225077ae3a5d291166b73b) @@ -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',