postmaster@, abuse@, security@: The Role Addresses Every Domain Needs

Which role email addresses every domain should have, why they matter, how to set them up in Microsoft 365 and Google Workspace, and how to lock down domains that never send mail — with PowerShell and GAM scripts.

Kim Nis Neuhauss24 min read[tech]

Almost every tenant I look at has the same gap: mail to postmaster@ bounces, abuse@ lands in a catch-all nobody reads, and admin@ turns out to be a personal mailbox of someone who left years ago. None of this hurts on a normal day. It hurts when another provider tries to tell you that your domain is sending spam, when a researcher wants to report a vulnerability, or when somebody asks a certificate authority for a TLS certificate for your domain and the validation mail goes to a mailbox you don’t control.

This post is my baseline for every domain I manage: which role addresses exist, what they are for, how to build them in Microsoft 365 and Google Workspace, and what to do with domains that are not supposed to handle mail at all. At the end there are scripts for both platforms.

The short version

Address Basis Required? Who reads it
postmaster@ RFC 5321, RFC 2142 Yes, for every domain that receives mail Mail admins
abuse@ RFC 2142 Yes, de facto Mail/security admins
security@ RFC 2142, RFC 9116 (security.txt) Strongly recommended Security team / IT lead
hostmaster@ RFC 2142, DNS SOA, CA validation Strongly recommended DNS admins
webmaster@ RFC 2142, CA validation Strongly recommended Web admins
admin@, administrator@ CA validation Reserve them IT admins only
dmarc-reports@ DMARC aggregate reports If you publish DMARC (you should) Nobody directly — a tool
tls-reports@ TLS-RPT (RFC 8460) If you publish TLS-RPT Nobody directly — a tool
privacy@ / dpo@ GDPR Art. 37(7) If you have a DPO Data protection officer
noc@ RFC 2142 Only if you run a network/AS Network operations

Every address that receives mail from the outside world must be readable by more than one person, must accept mail from anonymous external senders, and must never be a personal mailbox.

The addresses and why they matter

postmaster@

This is the one address that is not optional. RFC 5321, section 4.5.1, says that any system that accepts mail for delivery MUST support the mailbox postmaster (case-insensitive), and that SMTP systems should make every reasonable effort to accept mail directed to it. Other mail admins write to postmaster@ when your server rejects their mail, when your outbound mail looks broken, or when a bounce loop is going on.

Practical consequences:

  • It must exist for every domain that accepts mail, not just the primary one.
  • Don’t filter it aggressively. The mail you get here often looks like spam because it contains bounced spam.
  • No auto-replies, no ticket-system acknowledgements that end up in loops.

abuse@

RFC 2142 defines abuse@ for reports about inappropriate public behaviour — in practice: spam sent from your domain, phishing pages on your web space, compromised accounts. Mailbox providers, blocklist operators and other admins send reports here, often in the machine-readable ARF format. If nobody reads it, the next step for the reporter is a blocklist entry.

If your organisation holds its own IP space, the RIPE database also requires an abuse-c contact for it, and that should point to the same place.

security@

security@ is where vulnerability reports go. RFC 2142 lists it, and security.txt (RFC 9116) makes it discoverable: publish a file at /.well-known/security.txt with a Contact: mailto:security@example.com line and an Expires: date. Researchers look there first. Without a contact, the report goes to a generic contact form, to social media, or nowhere.

Because these reports can be sensitive, security@ is the role where you may want a smaller audience than for the others.

hostmaster@ and webmaster@

RFC 2142 assigns hostmaster@ to DNS and webmaster@ to the web server. hostmaster@ is also the conventional address in the SOA record of your zone (the RNAME field, written as hostmaster.example.com.), though with hosted DNS the provider usually puts its own address there.

The more important reason is certificate validation, which brings us to the next point.

admin@ and administrator@ — reserve them

The CA/Browser Forum Baseline Requirements allow a certificate authority to validate domain control by sending an email to a constructed address: admin@, administrator@, webmaster@, hostmaster@ or postmaster@ at the domain (method 3.2.2.4.4). Whoever can read one of these five mailboxes can obtain a publicly trusted TLS certificate for your domain.

The forum has voted to phase out email-based validation step by step (ballot SC-090, with this method scheduled to end in March 2028), but until then the rule is simple: none of these five local parts may ever be a regular user’s mailbox, and none of them may be free for anyone to register. If admin@example.com is your Microsoft 365 global admin account or the personal mailbox of your first employee, rename it and turn the address into a role address. A CAA record that limits which CAs may issue for your domain is a good additional safeguard.

Report sinks: dmarc-reports@ and tls-reports@

DMARC aggregate reports (rua=) and SMTP TLS reports (_smtp._tls, RFC 8460) arrive as XML or JSON attachments, daily, from every large mailbox provider. They are useless to read by hand and they will drown anything else in the same mailbox. Give them their own addresses, store them in a mailbox nobody gets notifications from, or — better — point rua= at a DMARC analysis service and keep the local address as a fallback.

Don’t send these reports to postmaster@.

Optional: privacy@, noc@, info@

  • privacy@ or dpo@: GDPR Art. 37(7) requires you to publish the contact details of your data protection officer. A role address survives a change of DPO.
  • noc@: only relevant if you operate a network, an AS or a hosting platform.
  • info@ / contact@: in Germany the imprint (§ 5 DDG) needs an email address. Use a role address here too, not a person.

Design principles that fit any tenant

Before looking at the platforms, the rules I apply everywhere:

  1. One object per role, not one per domain. Create postmaster@primary-domain once and add postmaster@ for every other mail domain as an additional address on the same object. Fewer objects, one place to manage members. (Google Workspace needs an exception for secondary domains, see below.)
  2. Never a personal mailbox. Role addresses must survive people leaving. Access goes through groups or permissions, not through someone’s inbox rules.
  3. Accept external, unauthenticated senders. The whole point is that strangers can write to you.
  4. At least two humans. Internal admins plus, where one exists, the managed services provider (MSP) that actually operates mail and DNS.
  5. Keep a copy. If messages are only fanned out to individual inboxes, nobody can later prove what was reported when. Keep an archive copy in a shared mailbox or group archive.
  6. Document who owns which role. A table in your IT documentation is enough.

Microsoft 365: Microsoft 365 group, distribution group or shared mailbox

Exchange Online gives you three sensible building blocks.

Microsoft 365 group Distribution group Shared mailbox
Where mail lives Group mailbox and a copy in each subscribed member’s inbox Only in each member’s inbox One central mailbox
External people (MSP) Yes, as guest users Yes, as mail contacts No
History / audit trail Yes, built in Only with an archive mailbox as member Yes, built in
Teams channel, files, runbooks Yes, if you add a team No No
Nested groups as members No, users and guests only Yes Via permissions
Prerequisite Guest access for groups (if MSP) None None

My default is a Microsoft 365 group. It combines what the other two only do halfway: every member gets the mail in their own inbox, the group mailbox keeps the complete history, and MSP technicians join as guests with their own identity — subject to your MFA and Conditional Access policies, visible in the sign-in logs, and removable one by one. If you add a team, you also get a channel to coordinate an incident in and a place for the runbook that says what to do with an abuse report.

Use a distribution group with mail contacts when the tenant doesn’t allow guests (many security baselines restrict B2B), or when the MSP’s recipient is a ticket system or a shared address that can’t redeem a guest invitation — Microsoft 365 groups can’t contain mail contacts. Delivery to a mail contact in a group is group expansion, not automatic forwarding, so the outbound spam policy’s block on external forwarding (the 5.7.520 bounce you get with mailbox forwarding) does not apply. Add a shared mailbox role-archive@ as an extra member if you want a central copy.

Use a shared mailbox for the report sinks dmarc-reports@ and tls-reports@ — nobody should get a notification for every XML file — and for small setups where only internal people handle the roles.

Things to get right with Microsoft 365 groups:

  • External senders. Like distribution groups, Microsoft 365 groups reject mail from outside the organisation by default. Set RequireSenderAuthenticationEnabled to $false — otherwise the sender gets a bounce and you never notice.
  • Membership is not subscription. Only subscribed members get the mail in their inbox; the others would have to look into the group mailbox. Turn on AutoSubscribeNewMembers and subscribe existing members explicitly. Guests are always subscribed when they are added as members.
  • Create the group in Exchange, then add the team. A team created in the Teams client produces a group that is hidden from Outlook and doesn’t subscribe its members. Create the group with New-UnifiedGroup (or in the admin center) and team-enable it afterwards with New-Team -GroupId.
  • Don’t create seven teams. One group per role is right for the addresses; a team is only worth it where people actually coordinate. Either team-enable just the groups you work in (typically abuse@ and security@), or put the operational roles (postmaster@, hostmaster@, webmaster@, admin@, administrator@) on one group as additional addresses and keep abuse@ and security@ separate.
  • Expiration policy. If the tenant has a group expiration policy for all groups, a quiet role group can expire and be deleted, addresses included. Don’t count on incoming external mail as activity — limit the policy to selected groups or make sure the role groups are not in scope.
  • Guest lifecycle. A guest per technician means someone has to remove the guest when the technician leaves the MSP. Put it into the offboarding agreement with your MSP and review the members quarterly (or with Entra access reviews, if licensed).
  • Guests see the whole team. Files and channels of a team are visible to its guests. Keep role teams for role work only.
  • Additional domains. Add the role addresses for all other accepted domains as proxy addresses (smtp:postmaster@second-domain.de) on the same object — this works the same for all three types.

Google Workspace: groups

Google Workspace has no shared mailbox; the building block is a Google Group with an email address.

  • abuse@ and postmaster@ are special. Google reserves them: you can’t use them as usernames or as aliases, but an admin can create groups with exactly these addresses in the Admin console (or via the API/GAM). Google itself monitors abuse@ and postmaster@ for every Workspace domain, which does not replace your own handling of reports.
  • Allow external senders. The group setting “Who can post” must be “Anyone on the web” (ANYONE_CAN_POST), and the organisation-wide Groups for Business setting must allow group owners to accept mail from outside the organisation.
  • External members. If the MSP should be a member, the group needs “Allow members outside your organization”, which in turn must be allowed in the organisation settings.
  • Spam moderation. By default, Groups holds suspected spam in a moderation queue that nobody looks at. Abuse reports are spam samples. Set spam moderation to deliver messages, and let each member’s own Gmail spam filter do its job.
  • Keep the archive on. A group’s conversation history is your audit trail.
  • Secondary domains vs. alias domains. Groups automatically receive addresses in alias domains. Secondary domains are separate: because the reserved role names can’t be added as group aliases, create one group per role per secondary domain and add the primary group as its only member.

Routing rules as a complement

The Gmail settings in the Admin console (Apps → Google Workspace → Gmail → Routing) can also send copies of mail to more recipients, external ones included: a routing rule for abuse@example.com with “Add more recipients” delivers every message to the MSP as well. Unlike group membership, a rule can also select by content, for example only messages with a DMARC report attachment or only ARF abuse reports.

I use this for selective cases, not as a replacement for group members:

  • Less visible. Group membership shows up wherever someone looks at the group. A routing rule sits in a settings page that few people open, and is easily forgotten when the MSP changes.
  • No scripting. To my knowledge there is no public API for Gmail routing settings, so GAM can’t create or audit them. You click them in by hand, per organisational unit, and changes can take up to 24 hours to apply.
  • Spam stays behind. Blatant spam is dropped before routing, and “Also reroute spam” doesn’t apply to groups. Abuse reports full of spam samples may not reach the MSP reliably.
  • Authentication at the receiver. Messages arrive at the MSP from Google’s servers on behalf of the original sender. Whether SPF passes there depends on sender rewriting, which Google doesn’t document clearly for this path. Test it, and let the MSP allow your tenant as a source if needed.

A good fit: sending only the DMARC aggregate reports to the MSP’s analysis service while the role group itself stays internal. Even better, if the MSP runs that service, put its address into rua= directly.

Domains that should not handle mail

Most organisations own far more domains than they use for mail: typo domains, old brand names, country variants, campaign domains. Those are the domains attackers prefer for spoofing, because nobody watches them. A domain without mail records is not “off” — without an MX record, senders fall back to the A record (“implicit MX”), and without SPF and DMARC nobody can tell whether mail claiming to come from it is legitimate.

Declare explicitly that the domain neither sends nor receives mail:

Record Value Effect
MX 0 . (Null MX, RFC 7505) “This domain accepts no mail.” Senders fail immediately instead of retrying for days. Must be the only MX record.
SPF v=spf1 -all No server is allowed to send for this domain.
DMARC v=DMARC1; p=reject; sp=reject; np=reject; adkim=s; aspf=s; rua=mailto:dmarc-reports@example.com Reject everything that fails, including subdomains and non-existent subdomains (np, new in RFC 9989). Reports go to your main domain.
DKIM (optional) *._domainkey → v=DKIM1; p= An empty key explicitly revokes any selector.

As a zone file for parked.example, with www redirecting to the main website:

; parked.example — no mail, website redirect only
parked.example.              3600 IN MX    0 .
parked.example.              3600 IN TXT   "v=spf1 -all"
_dmarc.parked.example.       3600 IN TXT   "v=DMARC1; p=reject; sp=reject; np=reject; adkim=s; aspf=s; rua=mailto:dmarc-reports@example.com"
*._domainkey.parked.example. 3600 IN TXT   "v=DKIM1; p="

; existing hosts need their own records — wildcards don't cover names that exist
www.parked.example.          3600 IN A     203.0.113.10
www.parked.example.          3600 IN MX    0 .
www.parked.example.          3600 IN TXT   "v=spf1 -all"

; everything else
*.parked.example.            3600 IN MX    0 .
*.parked.example.            3600 IN TXT   "v=spf1 -all"
text

Details that are easy to miss:

  • Wildcards only match names that don’t exist. www has an A record, so *.parked.example doesn’t apply to it, and mail to user@www.parked.example would go to the web server via implicit MX. Give every existing host name its own null MX and SPF record.
  • DMARC reports to another domain need permission. A receiver only sends reports for parked.example to dmarc-reports@example.com if example.com agrees, via a TXT record: parked.example._report._dmarc.example.com. IN TXT "v=DMARC1". Without it, many receivers silently drop the reports. Don’t point rua= to an address at the parked domain itself — it has a null MX.
  • p=reject from day one is fine here. The usual p=none monitoring phase exists to find legitimate senders. A domain that never sends has none. Check once that nothing (an old web form, a newsletter tool) does send, then enforce.
  • No role addresses needed. A domain with a null MX accepts no mail, so postmaster@ and friends have nothing to receive. Put the main domain’s contacts at the registrar and in security.txt. As a side effect, a null MX also closes the email path for certificate validation on that domain.
  • If the domain is in your tenant anyway (for example as a UPN suffix or for a website in SharePoint), don’t select the Exchange service when adding it in Microsoft 365, and don’t assign addresses in it.
  • Send-only domains are different. A domain that sends but never receives (say, a transactional mail subdomain) must not publish a null MX — receivers check that the sender domain can accept bounces and may reject mail otherwise. It needs a working MX for bounces, plus SPF, DKIM and DMARC like any sending domain.

The UK government publishes the same baseline as guidance for domains that don’t send email, and M3AAWG has a best-practices paper on protecting parked domains.

Script: Microsoft 365 with PowerShell

The script uses the ExchangeOnlineManagement module and supports all three building blocks via -Mode (default: UnifiedGroup). It checks that all domains are accepted domains, creates one object per role with addresses in all domains, and skips anything that already exists, with a warning — an existing admin@ user is something to review by hand, not to overwrite. Run it with -WhatIf first.

What -ExternalContacts means depends on the mode:

  • UnifiedGroup: addresses of existing guest users. Invite the MSP technicians beforehand (Entra admin center or New-MgInvitation); the script warns about addresses that aren’t guests. -InternalAdmins must be users, because Microsoft 365 groups can’t contain groups.
  • DistributionGroup: any external address; the script creates hidden mail contacts. -InternalAdmins may be users or mail-enabled security groups.
  • SharedMailbox: not supported, shared mailboxes are internal only.
#Requires -Modules ExchangeOnlineManagement
<#
.SYNOPSIS
    Creates role addresses (postmaster, abuse, security, ...) in Exchange Online.
.EXAMPLE
    ./New-RoleAddresses.ps1 -PrimaryDomain example.com -AdditionalDomains example.de `
        -InternalAdmins alice@example.com, bob@example.com `
        -ExternalContacts jane@msp.example -WhatIf
.EXAMPLE
    ./New-RoleAddresses.ps1 -PrimaryDomain example.com -InternalAdmins it-admins@example.com `
        -ExternalContacts support@msp.example -Mode DistributionGroup -WithArchive
#>
[CmdletBinding(SupportsShouldProcess)]
param(
    [Parameter(Mandatory)] [string] $PrimaryDomain,
    [string[]] $AdditionalDomains = @(),
    [Parameter(Mandatory)] [string[]] $InternalAdmins,
    # MSP: guest users (UnifiedGroup) or external addresses (DistributionGroup), may be empty
    [string[]] $ExternalContacts = @(),
    [ValidateSet('UnifiedGroup', 'DistributionGroup', 'SharedMailbox')]
    [string] $Mode = 'UnifiedGroup',
    # DistributionGroup only: adds a shared mailbox role-archive@ as member of every group
    [switch] $WithArchive
)

$Roles = [ordered]@{
    postmaster    = 'Postmaster'
    abuse         = 'Abuse Reports'
    security      = 'Security Contact'
    hostmaster    = 'Hostmaster (DNS)'
    webmaster     = 'Webmaster'
    admin         = 'Admin (reserved)'
    administrator = 'Administrator (reserved)'
}
# Machine-generated reports: always shared mailboxes, no fan-out
$ReportSinks = [ordered]@{
    'dmarc-reports' = 'DMARC Reports'
    'tls-reports'   = 'TLS-RPT Reports'
}

Connect-ExchangeOnline -ShowBanner:$false

$AllDomains = @($PrimaryDomain) + $AdditionalDomains
$Accepted = (Get-AcceptedDomain).DomainName
$Missing = $AllDomains | Where-Object { $_ -notin $Accepted }
if ($Missing) { throw "Not an accepted domain in this tenant: $($Missing -join ', ')" }

function Test-Recipient([string] $Address) {
    [bool](Get-Recipient -Identity $Address -ErrorAction SilentlyContinue)
}

function Wait-Recipient([string] $Address) {
    foreach ($i in 1..12) {
        if (Test-Recipient $Address) { return }
        Start-Sleep -Seconds 5
    }
    throw "$Address did not show up within 60 seconds."
}

function Test-RoleFree([string] $Address) {
    if (-not (Test-Recipient $Address)) { return $true }
    $type = (Get-Recipient -Identity $Address).RecipientTypeDetails
    Write-Warning "$Address already exists as $type - skipped."
    $false
}

function Get-FreeProxyAddresses([string] $Role) {
    foreach ($domain in $AdditionalDomains) {
        $address = "$Role@$domain"
        if (Test-Recipient $address) {
            Write-Warning "$address is already in use - not added, review manually."
        } else { $address }
    }
}

function New-RoleUnifiedGroup([string] $Role, [string] $DisplayName, [string[]] $Guests) {
    $primary = "$Role@$PrimaryDomain"
    if (-not (Test-RoleFree $primary)) { return }
    if (-not $PSCmdlet.ShouldProcess($primary, 'Create Microsoft 365 group')) { return }

    New-UnifiedGroup -DisplayName $DisplayName -Alias "role-$Role" -PrimarySmtpAddress $primary `
        -AccessType Private -Owner $InternalAdmins[0] | Out-Null
    Wait-Recipient $primary

    $settings = @{
        Identity                           = $primary
        # Without this, external senders get a bounce
        RequireSenderAuthenticationEnabled = $false
        # Members get every mail in their own inbox
        AutoSubscribeNewMembers            = $true
        HiddenFromExchangeClientsEnabled   = $false
        UnifiedGroupWelcomeMessageEnabled  = $false
    }
    $proxies = @(Get-FreeProxyAddresses $Role)
    if ($proxies) { $settings.EmailAddresses = @{ Add = $proxies } }
    Set-UnifiedGroup @settings

    Add-UnifiedGroupLinks -Identity $primary -LinkType Members -Links (@($InternalAdmins) + @($Guests))
    Add-UnifiedGroupLinks -Identity $primary -LinkType Owners -Links $InternalAdmins
    # Guests are subscribed automatically, internal members explicitly
    Add-UnifiedGroupLinks -Identity $primary -LinkType Subscribers -Links $InternalAdmins
    Write-Host "Created Microsoft 365 group $primary"
}

function New-RoleDistributionGroup([string] $Role, [string] $DisplayName, [string[]] $Members) {
    $primary = "$Role@$PrimaryDomain"
    if (-not (Test-RoleFree $primary)) { return }
    if (-not $PSCmdlet.ShouldProcess($primary, 'Create distribution group')) { return }

    New-DistributionGroup -Name "Role $Role" -DisplayName $DisplayName -Alias "role-$Role" `
        -PrimarySmtpAddress $primary -Type Distribution -Members $Members `
        -MemberJoinRestriction Closed -MemberDepartRestriction Closed | Out-Null
    Wait-Recipient $primary

    $settings = @{
        Identity                           = $primary
        # Without this, external senders get a bounce
        RequireSenderAuthenticationEnabled = $false
        ReportToOriginatorEnabled          = $false
    }
    $proxies = @(Get-FreeProxyAddresses $Role)
    if ($proxies) { $settings.EmailAddresses = @{ Add = $proxies } }
    Set-DistributionGroup @settings
    Write-Host "Created distribution group $primary"
}

function New-RoleSharedMailbox([string] $Role, [string] $DisplayName) {
    $primary = "$Role@$PrimaryDomain"
    if (-not (Test-RoleFree $primary)) { return }
    if (-not $PSCmdlet.ShouldProcess($primary, 'Create shared mailbox')) { return }

    New-Mailbox -Shared -Name "Role $Role" -DisplayName $DisplayName `
        -Alias "role-$Role" -PrimarySmtpAddress $primary | Out-Null
    Wait-Recipient $primary

    $settings = @{
        Identity                          = $primary
        MessageCopyForSentAsEnabled       = $true
        MessageCopyForSendOnBehalfEnabled = $true
    }
    $proxies = @(Get-FreeProxyAddresses $Role)
    if ($proxies) { $settings.EmailAddresses = @{ Add = $proxies } }
    Set-Mailbox @settings

    foreach ($admin in $InternalAdmins) {
        Add-MailboxPermission -Identity $primary -User $admin -AccessRights FullAccess `
            -InheritanceType All -AutoMapping $true | Out-Null
        Add-RecipientPermission -Identity $primary -Trustee $admin -AccessRights SendAs `
            -Confirm:$false | Out-Null
    }
    Write-Host "Created shared mailbox $primary"
}

# Human-facing roles
switch ($Mode) {
    'UnifiedGroup' {
        $guests = foreach ($address in $ExternalContacts) {
            $recipient = Get-Recipient -Identity $address -ErrorAction SilentlyContinue
            if ($recipient.RecipientTypeDetails -eq 'GuestMailUser') {
                $recipient.Guid.ToString()
            } else {
                Write-Warning "$address is not a guest user in this tenant - invite it first."
            }
        }
        foreach ($role in $Roles.Keys) { New-RoleUnifiedGroup $role $Roles[$role] @($guests) }
    }
    'DistributionGroup' {
        foreach ($address in $ExternalContacts) {
            if (Get-MailContact -Identity $address -ErrorAction SilentlyContinue) { continue }
            if ($PSCmdlet.ShouldProcess($address, 'Create mail contact')) {
                New-MailContact -Name "MSP $address" -ExternalEmailAddress $address | Out-Null
                Wait-Recipient $address
                Set-MailContact -Identity $address -HiddenFromAddressListsEnabled $true
            }
        }
        $members = @($InternalAdmins) + @($ExternalContacts)
        if ($WithArchive) {
            New-RoleSharedMailbox 'role-archive' 'Role Address Archive'
            $members += "role-archive@$PrimaryDomain"
        }
        foreach ($role in $Roles.Keys) { New-RoleDistributionGroup $role $Roles[$role] $members }
    }
    'SharedMailbox' {
        if ($ExternalContacts) {
            Write-Warning 'Shared mailboxes cannot include external people - use another -Mode.'
        }
        foreach ($role in $Roles.Keys) { New-RoleSharedMailbox $role $Roles[$role] }
    }
}

# Report sinks
foreach ($role in $ReportSinks.Keys) { New-RoleSharedMailbox $role $ReportSinks[$role] }
powershell

To add a team to one of the groups, use the MicrosoftTeams module:

Connect-MicrosoftTeams
New-Team -GroupId (Get-UnifiedGroup -Identity abuse@example.com).ExternalDirectoryObjectId
powershell

After the run, send a test mail from an external address (a private webmail account is fine) to every role address in every domain. That is the only test that catches a forgotten RequireSenderAuthenticationEnabled or a transport rule that drops mail from outside.

Script: Google Workspace with GAM

The script uses GAM7. Before running it, make sure the Admin console allows it: Apps → Google Workspace → Groups for Business → Sharing settings must allow group owners to accept incoming mail from outside the organisation and, if you add the MSP, to add external members.

#!/usr/bin/env bash
# Creates role addresses as Google Groups with GAM7.
# Idempotent: existing groups are left alone, existing members produce a warning.
set -uo pipefail

PRIMARY_DOMAIN="example.com"
SECONDARY_DOMAINS=("example.de")         # secondary domains only; alias domains are automatic
ADMINS=("alice@example.com" "bob@example.com")
MSP_CONTACTS=()                          # e.g. ("support@msp.example"), may be empty

ROLES=(postmaster abuse security hostmaster webmaster admin administrator)
REPORT_SINKS=(dmarc-reports tls-reports)

# Anyone may post, nothing is held for moderation, conversation history is kept.
BASE_SETTINGS=(
  whocanpostmessage anyone_can_post
  messagemoderationlevel moderate_none
  spammoderationlevel allow
  whocanjoin invited_can_join
  whocanviewgroup all_members_can_view
  whocanviewmembership all_members_can_view
  whocandiscovergroup all_members_can_discover
  isarchived true
)

if ((${#MSP_CONTACTS[@]})); then
  EXTERNAL=(allowexternalmembers true whocanaddexternalmembers only_admins_can_add_external_members)
else
  EXTERNAL=(allowexternalmembers false)
fi

group_exists() {
  gam info group "$1" nousers >/dev/null 2>&1
}

ensure_group() {  # <address> <name> <description> [extra settings...]
  local address=$1 name=$2 description=$3
  shift 3
  if group_exists "$address"; then
    echo "exists:  $address"
  else
    gam create group "$address" name "$name" description "$description" \
      "${BASE_SETTINGS[@]}" "$@"
  fi
}

# Human-facing roles in the primary domain
for role in "${ROLES[@]}"; do
  group="$role@$PRIMARY_DOMAIN"
  ensure_group "$group" "Role: $role" "Role address $role@ - do not delete" "${EXTERNAL[@]}"
  # ${arr[@]+...} keeps an empty array from tripping set -u in older bash versions
  for member in "${ADMINS[@]}" ${MSP_CONTACTS[@]+"${MSP_CONTACTS[@]}"}; do
    gam update group "$group" add member "$member"
  done
done

# Report sinks: admins are members but get no mail, reports stay in the group archive
for role in "${REPORT_SINKS[@]}"; do
  group="$role@$PRIMARY_DOMAIN"
  ensure_group "$group" "Reports: $role" "Machine-generated reports" \
    allowexternalmembers false enablecollaborativeinbox true
  for member in "${ADMINS[@]}"; do
    gam update group "$group" add member delivery nomail "$member"
  done
done

# Secondary domains: abuse@ and postmaster@ cannot be group aliases,
# so every role gets its own group that only contains the primary group.
for domain in "${SECONDARY_DOMAINS[@]}"; do
  for role in "${ROLES[@]}"; do
    group="$role@$domain"
    ensure_group "$group" "Role: $role ($domain)" "Forwards to $role@$PRIMARY_DOMAIN" \
      allowexternalmembers false
    gam update group "$group" add member "$role@$PRIMARY_DOMAIN"
  done
done
bash

Check the result with gam print groups query "email:postmaster*" settings or gam info group postmaster@example.com, and then do the same external test mail as on the Microsoft side.

Checklist

  • postmaster@ and abuse@ exist for every domain that receives mail and accept external mail
  • security@ exists and is published in /.well-known/security.txt
  • hostmaster@, webmaster@, admin@, administrator@ are role addresses, not personal mailboxes
  • At least two people (internal admins and, if any, the MSP as guests or mail contacts) receive every role address
  • Role groups are subscribed, accept external senders and are out of scope of the group expiration policy
  • A central copy exists (shared mailbox or group archive)
  • DMARC and TLS reports go to dedicated sinks or a reporting service
  • Every domain without mail has null MX, v=spf1 -all and DMARC p=reject, including existing host names
  • Cross-domain DMARC reports are authorised with _report._dmarc records
  • An external test mail to every role address arrived

References

esc

↑↓ navigate↵ opentab sectionesc close

man xunil

/ ⌘K
open search & command palette
1
go to value-creation
2
go to tech
3
go to about
4
go to now
j k
next / previous post in a list
y
copy link to the current post
?
show this help
esc
close dialogs

In the palette, type : for commands, e.g. :theme amber.