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

Accepted Answer
0 votes

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
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

61 views 2 6
View post

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