Zammad Console

docker exec -it zammad bash
cd /opt/zammad
>/opt/zammad# rails c
>>

>>Setting.get('system_bcc')
>>Setting.set('system_bcc', 'xxxx@xxxxx.de')
abschalten:
>>Setting.set('system_bcc', '')

>> p Delayed::Job.count
>> p Delayed::Job.first
>> p Delayed::Job.last

>> p Delayed::Job.find(xxxxx).destroy

xxxxx is the Id of my Job (found in the LogFile)


>> p Delayed::Job.where('attempts > 0')


By default Zammad will not display the E-Mail-Addresses of customers. The below option allows you to change this behavior.
>>Setting.get('ui_user_organization_selector_with_email')
>>Setting.set('ui_user_organization_selector_with_email', true)

To force Zammad to reattempt to parse those mails, run the following command:
>>Channel::EmailParser.process_unprocessable_mails

The below command will do a manual fetch of mail channels. This will also show erors that might appear within that process.

>> Channel.fetch
Step 1: Select customers by email address
>> customer_emails = %w[customer@example.com customer@example.org]

>> customers = User.joins(roles: :permissions).where(email: customer_emails, roles: { active: true }, permissions: { name: 'ticket.customer', active: true }).where.not(id: 1)
Step 2: Preview affected users & tickets
>> puts customers.map { |user| <<~PREVIEW }.join("\n")
     Customer #{user.fullname}/#{user.id}/#{user.email} has #{Ticket.where(customer_id: user.id).count} tickets #{Ticket.where(customer_id: user.id).pluck(:number)}
   PREVIEW
Step 3: Proceed with deletion
>> customers.find_each do |user|
     puts %{Preparing deletion of customer "#{user.fullname}" (and #{Ticket.where(customer_id: user.id).count} associated tickets)}

     Ticket.where(customer: user).find_each do |ticket|
       puts "  Deleting ticket ##{ticket.number}..."
       ticket.destroy
     end

     puts "  Removing references for user with email #{user.email}..."
     ActivityStream.where(created_by_id: user.id).update_all(created_by_id: 1)
     History.where(created_by_id: user.id).update_all(created_by_id: 1)
     Ticket::Article.where(created_by_id: user.id).update_all(created_by_id: 1)
     Ticket::Article.where(updated_by_id: user.id).update_all(updated_by_id: 1)
     Store.where(created_by_id: user.id).update_all(created_by_id: 1)
     StatsStore.where(created_by_id: user.id).update_all(created_by_id: 1)
     Tag.where(created_by_id: user.id).update_all(created_by_id: 1)
     OnlineNotification.find_by(user_id: user.id)&.destroy!

     puts "  Deleting #{user.fullname}..."
     user.destroy
   end

Find user

In order to work on user information or to check for specific information, you’ll need to find it first.

>> User.find(4)                       # We already know the ID of the user
>> User.find_by(email: 'your@email')  # Searching for the user by his E-Mail-Address
>> User.find_by(login: 'john.doe')    # Searching for the user by his login

Re-activate a locked user account

It sometimes happens that a user locks himself out by wildly trying the wrong password multiple times. Depending on your maximum failing login count (default: 10 times), Zammad might lock the account. The user can’t login any more (forever) if he doesn’t change the password or you reset the counter.

>> u=User.find(**USERID**)
>> u.login_failed=0
>> u.save!

You can also double check if the account is locked by running the following (result needs to be 1 above your limit, so 11 for the default of 10 failing logins)

>> User.find(**USERID**).login_failed

Change / Update E-Mail-Adress of User

If needed, you can simply change the E-Mail-Address of the user.

Note

Please note that the login attribute is not affected by this and Zammad thus might show different information within the UI.

>> u = User.find(**USERID**)
>> u.email = 'user@exmaple.com'
>> u.save!

You need to find the User-ID of the user first for this.

Change / Update Login name of User

Change the user name of the user (e.g. if you want to login with a shorter username instead of a mail address)

>> u = User.find(**USERID**)
>> u.login = 'user@exmaple.com'
>> u.save!

You need to find the User-ID of the user first for this.

Set admin rights for user

Don’t have access to Zammad anymore? Grant yourself or another user administrative rights.

>> u = User.find_by(email: 'you@example.com')
>> u.roles = Role.where(name: ['Agent', 'Admin'])
>> u.save!

Set password for user

You or the user did forget his password? No problem! Simply reset it by hand if needed.

>> User.find_by(email: 'you@example.com').update!(password: 'your_new_password'

Removing tickets (and their articles)

# Delete a ticket (specified by database ID)
>> Ticket.find(4).destroy

# Delete all tickets
>> Ticket.destroy_all

# Keep some tickets (specified by database ID); delete the rest
>> tickets_to_keep = [1, 2, 3]
>> Ticket.where.not(id: tickets_to_keep).destroy_all