saebel But, I've got somewhere around 100 email addresses that get pointed to seven mail boxes that I really don't want to have to recreate one by one.
I'm in a similar position.
One thing you can do now, is use the OS API with a Python script that's modified from the example here:
https://community.opalstack.com/d/105-api-dox/5
That version will only add one address at a time.
I've updated it a little to loop through a Python dictionary.
- It's not 100% automatic like @sean's migration script will be, but if you're comfortable with RegEx and a text editor, it should be better than doing it manually and one-at-a-time through the OS CP.
- Forwards will be the easiest, since you just fill in
source
and forwards
with the literal values.
- Delivering to a Mail User will be a little annoying because you'll need to find and use their corresponding UUIDs and not just the mailbox name.
- You can populate the inline
EMAILS_TO_ADD
variable at the top, or uncomment out two lines (lines 41-42)
to json.load()
an external .json
file.
from requests.auth import AuthBase
import requests
import json
TOKEN = "YOUR_API_TOKEN"
EMAILS_TO_ADD = [
{
"source": "sourceaddress1@domain.com",
"destinations": ["UUID1", "UUID2"],
"forwards": ["email@domain.com", "email2@domain.com"]
},
{
"source": "sourceaddress1@domain.com",
"destinations": ["UUID3", "UUID4"],
"forwards": ["email3@domain.com", "email4@domain.com"]
},
{
"source": "sourceaddress1@domain.com",
"destinations": ["UUID1", "UUID4"],
"forwards": ["email2@domain.com", "email3@domain.com"]
}
]
class TokenAuth(AuthBase):
"""Attaches HTTP Token Authentication to the given Request object."""
def __init__(self, token):
# setup any auth-related data here
self.token = token
def __call__(self, r):
# modify and return the request
r.headers["Authorization"] = f"Token {self.token}"
r.headers["Content-Type"] = "application/json"
return r
# UNCOMMENT these two lines line if you want to use an external .json file instead of writing the dict above.
# with open('os_api--email-addresses.json') as f:
# EMAILS_TO_ADD = json.load(f)
for item in EMAILS_TO_ADD:
r = requests.post(
f"https://my.opalstack.com/api/v0/mail/add/",
auth=TokenAuth(TOKEN),
json={
"source": item["source"],
"destinations": [],
"forwards": item["forwards"],
},
)
# Debugging Output
print(r.status_code)
print(r.text)
You probably already realize this, and are avoiding it because of the UUID issue or something else.
But even though it's a little less ideal than an automated WF -> OS migration script, it's a little better than the OS CP for 100+ addresses. At least for now.
I hope this helps.