I am sending emails using javax mail APIs in a batch process. Due to an error in configuration the 'from' address got set to multiple comma separated email addresses.
The code snippet is like the following:
MimeMessage msg = new MimeMessage (mailSession);
...
msg.setFrom(new InternetAddress(from));
I did not get exceptions but I am not sure if the emails were sent correctly; and if they were sent whether they would end up in recipient's spam.
Is it valid to send emails using java APIs where 'from' email address has multiple values?
CodePudding user response:
The constructor InternetAddress(String)
should throw an exception, if parsing the given string does not precisely return a single, valid email-address. So, I'll assume that your given "from" parameter is parsed into a single e-mail-address which is wrong in any case.
According to RFC822, the FROM field of an email must only contain a single "identity"