Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to send E-Mails based on Confluence Page Content with REST-API

Artur A_ I'm New Here May 06, 2021

I would like to write a java based app that sends e-mails using the confluence REST-API.

Formerly I wrote a bot that did that using the frontend after updating the page(not nice, but worked fine). The basic steps were:

1. Update(PUT) page with new content (daily report)
2. Send e-mail using the frontend (share feature)

I can imagine the app working like:

Option1: Use PUT to update page, use an not yet known way to send an email using Rest-API.
Option2: Use PUT to update page, use another way to send an e-mail with the already available content using Java. 

I think option2 would be enough to get the results we need. 
I still would like to know if there is a "nice" way of confluence doing that.

Any hints appreciated. Thank you.


1 answer

1 accepted

1 vote
Answer accepted
Thomas Deiler Community Leader May 06, 2021

Dear @Artur A_ ,

welcome to the community.

Unfortunately the REST API doesn't allow to direct send mails. They are only sent when you change content and somebody is a watcher. (Btw. You can modify the watchers with REST.)

So I recommend option 2. Java Mail Api is simple to use:

import javax.mail.*;
import java.util.Properties;

public class SendMail {

private Properties props;
private Session session;

public SendMail (String host, String port) {
this.props = new Properties();
this.props.put("", host);
this.props.put("mail.smtp.port", port);
this.props.put("mail.smtp.auth", "false");
this.session = Session.getDefaultInstance(props, null);

public void send(String subject, String msgBody, String from, String[] to) {
try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
for (int i=0; i<to.length; i++) {
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to[i]));
} catch (MessagingException e) {
String msg = "Send failed. " + e.getMessage();
throw new RuntimeException(msg);


 So long


Artur A_ I'm New Here May 06, 2021

Hello Thomas,

thank you for your swift and clear answer. Much appreciated.

Thomas Deiler Community Leader May 07, 2021

Dear @Artur A_ 

don't forget to press the "green accept answer" button to indicate other readers the successful answering of your question.

So long

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Miss the Confluence demos at Team 21? Watch them here!

Phew, Atlassian Team 2021 blew by. With dozens of demos and a handful of keynotes, you may have missed some of the awesome Confluence Cloud sessions. Don't' worry, you can watch them all here or on Y...

359 views 2 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you