Getting "SMTP can only send RFC822 message" with sending email in Confluence Server

I am getting below error during sending the email address from Confluence Server.
Working as expected in Jira
com.atlassian.mail.MailException: javax.mail.MessagingException: SMTP can only send RFC822 messages

I am using the below code for sending Email in Confluence
SMTPMailServer mailServer = MailFactory.getServerManager().getDefaultSMTPMailServer();
Email email = new Email(confluenceUser.getEmail());

Is there any way to solve this issue?

Thanks in advance.

Hello @VikasNare

That error comes from the JavaMail library

Notice how it is doing a type check (with instanceof) which suggests a potential class loading issue :thinking:

I know that Confluence and Jira ship with different versions of that library, so questions :

  • which versions of the products are you testing this code on ?
  • are you by any chance bundling your copy of JavaMail ?
  • how is this code being called ? through a rest resource ? a long running task ? an xwork action ?

Apologies for answering your question with yet more questions , thing is … “it works on my machine” :woman_shrugging:

1 Like