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

**URL:** <https://community.developer.atlassian.com/t/getting-smtp-can-only-send-rfc822-message-with-sending-email-in-confluence-server/38314>\
**Category:** Confluence Development\
**Tags:** confluence, confluence-server, email\
**Created:** [May 15, 2020, 10:04am UTC](https://community.developer.atlassian.com/t/getting-smtp-can-only-send-rfc822-message-with-sending-email-in-confluence-server/38314 "2020-05-15T10:04:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VikasNare](https://avatars.discourse-cdn.com/v4/letter/v/dec6dc/32.png) [@VikasNare](https://community.developer.atlassian.com/u/VikasNare)\
**Post date:** [May 15, 2020, 10:04am UTC](https://community.developer.atlassian.com/t/getting-smtp-can-only-send-rfc822-message-with-sending-email-in-confluence-server/38314/1 "2020-05-15T10:04:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![viqueen](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/viqueen/32/38462_2.png) [@viqueen](https://community.developer.atlassian.com/u/viqueen)\
**Post date:** [May 16, 2020, 2:43pm UTC](https://community.developer.atlassian.com/t/getting-smtp-can-only-send-rfc822-message-with-sending-email-in-confluence-server/38314/2 "2020-05-16T14:43:10Z")

</div>

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](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” 🤷‍♀️
