Affects: 5.3.23 and other versions


After spending some time diagnosing bounded Google mails, we discovered that if we use MimeMessageHelper to add multiple email addresses with setTo(), setCc(), or setBcc(), multiple TO/CC/BCC headers will be added to the original email. We received bounced emails due to RFC 5322 format errors recently because some Gmail servers began enforcing RFC 5322.

According to RFC 5322, there can be no more than one TO/CC/BCC header (see page 22 on https://www.rfc-editor.org/rfc/rfc5322). Emails with multiple TO/CC/BCC headers will be bounced if they are routed to the Gmail servers that are checking RFC 5322.

I tested JavaMailSender with MimeMessageHelper which comes with the Spring Framework libraries and can reproduce multiple TO/CC/BCC headers. The email may go through Gmail or get bounced because of the RFC 5322 format error.

Comment From: sbrannen

Hi @Huaichen2021,

Thanks for reporting the issue.

In order to help us analyze the behavior you're reporting, please provide a minimal example application that reproduces the behavior -- for example, as a GitHub repository that we can check out or a ZIP file, so that we can run the code.

Thanks

Comment From: Huaichen2021

Hi Sbrannen,

The issue didn't occur with my sample program when I tries to reproduce it. Looking at the source code, I found that the MimeMessageHelper is using the MimeMessage library from JavaMail library, so it is not an issue with the MimeMessageHelper. The JavaMail library is actually the one that implements setTo() when MimeMessageHelper called it.

Although I have updated the JavaMail library in our POM file to the latest version (1.6.2), an old library of JavaMail has been deployed with org.apache.axis2. It seems that MimeMessageHelper is loading the old JavaMail class even though the new library is also included in the deployment file.

After I excluded JavaMail from org.apache.axis2, MimeMessageHelper is working properly. Sorry for bothering you. The issue can be closed. Thank you for taking the time to look into this.

Huaichen

Comment From: bclozel

Thanks for letting us know @Huaichen2021