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

0 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

67 views 0 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you