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());
email.setFrom(mailServer.getDefaultFrom());
email.setSubject(subject);
email.setBody(body);
email.setMimeType(“text/html”);
mailServer.send(email);
Is there any way to solve this issue?
Thanks in advance.
Hello @VikasNare
That error comes from the JavaMail library
https://github.com/eclipse-ee4j/mail/blob/master/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java#L1247
Notice how it is doing a type check (with instanceof
) which suggests a potential class loading issue 
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” 
1 Like