JasperReport Server email by Sendgrid

2019-09-01 17:17发布

问题:

When trying to send email from JasperReport Server using Sendgrid it throws error

2016-05-22 05:27:20,212 ERROR ReportExecutionJob,quartzScheduler_Worker-1:349 - The job error notification was not completed. An error occurred while sending it. org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 550 Unauthenticated senders not allowed ; message exception details (1) are: Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 550 Unauthenticated senders not allowed

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:416)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:336)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJobMailNotificationImpl.sendMailNotification(ReportExecutionJobMailNotificationImpl.java:139)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.sendMailNotification(ReportExecutionJob.java:1059)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.executeAndSendReport(ReportExecutionJob.java:570)
at com.jaspersoft.jasperserver.api.engine.scheduling.quartz.ReportExecutionJob.execute(ReportExecutionJob.java:241)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)

Though username and password works, Is it possible to send mail using Sendgrid in JasperServer? It was tried using below configuration.

report.scheduler.mail.sender.host=smtp.sendgrid.net report.scheduler.mail.sender.username=*****

report.scheduler.mail.sender.password=******

report.scheduler.mail.sender.from=no-reply@stutzen.me report.scheduler.mail.sender.protocol=smtp

report.scheduler.mail.sender.port=2525

回答1:

Need a additional configuration in

/jasperserver/WEB-INF/applicationContext-report-scheduling.xml

       <property name="javaMailProperties">
            <props>
                <prop key="mail.smtp.sendpartial">true</prop>
                <prop key="mail.smtp.auth">true</prop>
            </props>
        </property>

mail.smtp.auth needs to be true for Sendgrid