Alias visibility

Is there a way to let non-admin users see what aliases they’ve been assigned? I’ve got a bunch of aliases for my main (non-admin) account and it’s a bit annoying to have to log in with the admin account to see them. Likewise for family members.

I hope someone chimes in with some way to do this. I tried to find some way through Roundcube, but at least as configured it at least isn’t obvious. There is an option to create ‘Identies’, which makes it easy to send mail as an alias, but they can only be updated manually one at a time.

Another option is you could create a subdomain for each user and then make a catchall that points at a subdomain address, that way they can just make up their aliases on the fly and have them arrive in an inbox they have access to.

Interested as well. I suppose the best way would be to query the database in /home/user-data/mail/users.sqlite and send the output of the query to a CSV file using .mode csv.

If you use NextCloud, save it directly into /home/user-data/owncloud/user@example.com/file folder for the specific person. Could also a shell script and a cronjob to do it however often seems necessary, to automate it without having to manually do it every time.

I can’t really be more specific since I’ve never looked at the database and have never used SQLite, but that seems like a good starting point. Might have to look into it more if I get the time.

EDIT.
Okay, here’s what I have so far.

Step 1:
SSH into server, switch to root user

sudo -s

Step 2:
Query the database, dump into CSV

sqlite3 -header -csv /home/user-data/mail/users.sqlite "SELECT email FROM users WHERE email LIKE 'userX@example.com' UNION SELECT source FROM aliases WHERE destination LIKE '%userX@example.com%';" > /home/user-data/owncloud/userX@example.com/files/email-aliases.csv
  • Change userX@example.com in all three places in that line to the actual mail user’s mailbox.
  • Make sure to keep the % wildcards wrapped around the user’s email in this part: WHERE destination LIKE '%userX@example.com%';. This is important since there can be multiple email addresses in the destination (Forwards To in MiaB admin panel).
  • Note that the assumption is that “Any mail user listed in the Forwards To box can send mail claiming to be from the alias address” is selected in the admin panel. Otherwise, you’ll want to swap WHERE destination with WHERE permitted_senders. This assumption is more than likely what most users are doing; permitted senders aren’t as commonly set and will be empty values.
  • Repeat for every user

Step 3:
Change permissions so NextCloud can read file:

chown -R www-data:www-data /home/user-data/owncloud/userX@example.com/files/email-aliases.csv
  • If you’re doing multiple users, just chown the entire owncloud folder instead of repeating each time.

Step 4:
Scan NextCloud files so that the CSV shows up:

cd /usr/local/lib/owncloud
sudo -u www-data php occ files:scan --all

Done. Now simply go into NextCloud and the email-aliases.csv file will be in the base folder. Example:
email-aliases-example

This can all be done using a bash script. If I get the time I’ll make it, but hopefully this is enough to get people started. Would just need to create the script and use the root crontab to execute it. Keeps things automated.

1 Like