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 email all space admins?

23-Oct-13

Good afternoon,
We're running Confluence v5.0.3. How can a Confluence administrator send a mass email to all the space administrators?

Thanks in advance for your time and consideration!

2 answers

1 accepted

It is not possible AFAIK. See an open future request: https://jira.atlassian.com/browse/CONF-23935

I created a two-step process to do this. First, there's a user macro that generates a list of all space admin's usernames, and then an XML/RPC script (running on my laptop outside the wiki) that gets and prints all the emails.

Here's the macro:

## Macro title: Space Administrators
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Based on code developed by: Andrew Frayling
## Date created: 28/04/2012
## Modified by Jonathan Simonoff 8/28/2012
## Macro to list all users and groups with the permission to administer any space
## @param 0:title=Email only|type=boolean
#set($helper=$action.getHelper())
#if($param0)
#foreach ($space in $spaceManager.getAllSpaces())
#if($space.isGlobal())
#foreach ($permission in $space.getPermissions())
#if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
#set ($userName=$permission.getUserName())
##$helper.renderConfluenceMacro("{user-info:user=$userName|display=email}")<br/>
$userName 
#end
#end
#end
#end
#else
<table class="confluenceTable">
#foreach ($space in $spaceManager.getAllSpaces())
 #if($space.isGlobal())
   #set($spacekey=$space.getKey())
<tr>
        <td class="confluenceTd">$helper.renderConfluenceMacro("[$spacekey:]")</td>
<td class="confluenceTd">$spacekey</td><td class="confluenceTd">
  #foreach ($permission in $space.getPermissions())
    #if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
#set ($userName=$permission.getUserName())
##$helper.renderConfluenceMacro("{user-info:user=$userName|display=email}") 
$userName
<br/>
 #end
  #end
 </tr>
 
  #end
#end
</table>
#end

 

Here's the script to get the email addresses from the usernames the macro generates. This assumes the macro has been put on a page called "Space Administrators" in a space with the key "space":

 

#!/usr/bin/python
  2 #
  3 import sys
  4 from xmlrpclib import Server
  5 s=Server("your-base-addr/rpc/xmlrpc")
  6 token=s.confluence2.login("adminuser","password")
  7 # Get the space admins page
  8 page=s.confluence2.getPage(token,"space","Space Administrators")
  9 spaceadmins=s.confluence2.renderContent(
 10   token,"wiki", page["id"],"",{"style":"clean"})
 11 # Get their emails
 12 adminlist=spaceadmins.splitlines()
 13 adminlist=sorted(set(adminlist)) #remove duplicates (and sort)
 14 for admin in adminlist:
 15   if "<" in admin: continue
 16   if admin:
 17     try:
 18       user=s.confluence2.getUser(token,admin) # Skips blanks
 19       print user["email"]
 20     except:
 21       continue

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Next-gen

Keyboard shortcuts have arrived for next-gen projects!

...ollected feedback from users around the lack of shortcuts, and we’re here to address that: In next-gen projects, I miss the keyboard shortcuts badly. This is particularly true on the Board, but also i...

278 views 2 5
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