Change email adress of all users directly in the database

Hello,

for a test environment i’ve made a copy of my productive server. To ensure that no real customer gets an email while i’m testing some things, i want to change all email adresses of all users to a domain, where i have a catchall activated.

I have a SQL statement which updated the “email”-field in the users table and the “from”-field in the ticket_articles table. But the test system still shows the old email adresses. Is there anything what i’m missing or is my way of changing all data not possible?

For my test server i need the tickets from the productive server because i want to test some kind of mass updating tickets (~500-1000 tickets) via the api.

Hi @richie_77,

not sure if it is within the scope of your testing, but I can suggest to use mailpit as local mailserver instead of your production system.

This enables you to test stuff with a virtual mail server.
More information in this thread:

If it is out of scope, excuse my failed response to your specific request.

Best,
Skip

Changing values directly inside the database, without Zammad in between in any way is not supported nor encouraged. You’re skipping important data consistency checks and will run in all sort of issues, e.g. in terms of caching etc.

This is out of scope. You’re on your own.

The other option, instead of going through the SQL and change e-mail addresses is to export the users through the API and update them with the new and changed e-mail address again through the API.

Or the rails console. :slight_smile:

That was my naive idea of ​​an easy way. :face_with_peeking_eye:

I will try some code blocks/for-each-loops in the rails console.

The mailserver is already a virtualized postfix instance. Sure, i could make a copy of the mailserver and do some blocking of all outbound mails or some kind of redirecting, but that would be more work. The “changing all mail addresses”-way looks easier to implement.