How To

Configure Domains and User Accounts on iRedMail Server

Once iRedMail is installed, the next step is adding mail domains and user accounts. You can do this through the iRedAdmin web panel or directly in the database. This guide covers both approaches, along with the DNS records each new domain needs to actually receive and send email.

Original content from computingforgeeks.com - post 36468

Current as of March 2026. Works with iRedMail 1.7.x on any supported OS (Ubuntu 24.04/22.04, Debian 12, Rocky Linux 10/9, AlmaLinux 10/9, FreeBSD 14).

If you haven’t installed iRedMail yet, start with the installation guide for your OS: Ubuntu 24.04/22.04, Debian 12, or Rocky Linux / AlmaLinux.

Add a Mail Domain via iRedAdmin

Log in to iRedAdmin at https://mail.example.com/iredadmin/ with your postmaster credentials.

From the dashboard, click Add in the top menu, then select Domain. Enter the new domain name (e.g., newdomain.com) and configure these settings:

  • Domain Name: the bare domain, e.g. newdomain.com
  • Mail quota: total storage limit for all mailboxes under this domain (default is 0 for unlimited)
  • Max number of users: leave at 0 for unlimited, or set a cap
  • Max number of aliases: same as above

Click Add to save. The domain appears immediately in the Domains list.

Add a Mail Domain via CLI

If you prefer the command line, or need to script bulk domain additions, insert directly into the database. The examples below use PostgreSQL (adjust for MySQL/MariaDB if that’s your backend).

Connect to the vmail database:

sudo -u postgres psql -d vmail

Insert the new domain:

INSERT INTO domain (domain, transport, active)
VALUES ('newdomain.com', 'dovecot', 1);

Verify the domain was added:

SELECT domain, active FROM domain ORDER BY domain;

You should see the new domain listed with active = 1.

For MariaDB/MySQL backends, connect with mysql -u root -p vmail and the same SQL works.

Create a User Account via iRedAdmin

In iRedAdmin, click Add then User. Fill in the required fields:

  • Mail Address: the local part (e.g., john) and select the domain from the dropdown
  • Display Name: the user’s full name
  • New password / Confirm password: set a strong password
  • Mailbox quota: per-user storage limit in MB (0 for domain default)

Click Add to create the account. The user can immediately log in to Roundcube at https://mail.example.com/mail/ or SOGo at https://mail.example.com/SOGo/.

Create a User Account via CLI

For scripted user creation, generate a password hash first:

doveadm pw -s SSHA512 -p 'UserPassword123'

This outputs a hash like:

{SSHA512}k3x9y7z...

Insert the user into the database (PostgreSQL example):

sudo -u postgres psql -d vmail
INSERT INTO mailbox (username, password, name, maildir, quota, domain, active, local_part)
VALUES (
  '[email protected]',
  '{SSHA512}YOUR_HASH_HERE',
  'John Smith',
  'newdomain.com/j/o/h/john-2026.03.28.01.02.03/',
  1024,
  'newdomain.com',
  1,
  'john'
);

The maildir path follows iRedMail’s hashed directory layout: domain/first_char/second_char/third_char/username-timestamp/. The quota value is in MB.

Also add the user to the forwardings table so local delivery works:

INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding)
VALUES ('[email protected]', '[email protected]', 'newdomain.com', 'newdomain.com', 0);

Set Up DNS Records for the New Domain

Adding a domain in iRedMail only configures the server side. For email to actually flow, you need DNS records on the new domain. Without these, incoming mail won’t reach your server and outgoing mail will land in spam.

MX record

Points email delivery for the new domain to your mail server:

newdomain.com.    IN    MX    10    mail.example.com.

SPF record

Authorizes your mail server to send email for the new domain:

newdomain.com.    IN    TXT    "v=spf1 mx a:mail.example.com -all"

DKIM record

iRedMail generates one DKIM key per domain. Generate a key for the new domain:

sudo amavisd genrsa /var/lib/dkim/newdomain.com.pem 2048

Add the new domain to the Amavisd DKIM signing configuration. Open /etc/amavis/conf.d/50-user and add the domain to the dkim_key list:

sudo vi /etc/amavis/conf.d/50-user

Find the dkim_key section and add a line for the new domain:

dkim_key('newdomain.com', 'dkim', '/var/lib/dkim/newdomain.com.pem');

Also add the domain to the @dkim_signature_options_bysender_maps array in the same file. Then restart Amavisd:

sudo systemctl restart amavis

Retrieve the public key for DNS:

sudo amavisd showkeys

Create a TXT record at dkim._domainkey.newdomain.com with the public key from the output. Verify the key propagated:

sudo amavisd testkeys

DMARC record

_dmarc.newdomain.com.    IN    TXT    "v=DMARC1; p=reject; rua=mailto:[email protected]"

Verify DNS propagation

Check that all records resolve correctly:

dig MX newdomain.com +short
dig TXT newdomain.com +short
dig TXT dkim._domainkey.newdomain.com +short
dig TXT _dmarc.newdomain.com +short

Create Email Aliases

Aliases forward email from one address to another without creating a full mailbox. In iRedAdmin, go to Add then Alias. You can also add them via SQL:

INSERT INTO alias (address, domain, active)
VALUES ('[email protected]', 'newdomain.com', 1);

INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding)
VALUES ('[email protected]', '[email protected]', 'newdomain.com', 'newdomain.com', 1);

This forwards all mail sent to [email protected] to [email protected].

Test the New Domain

Send a test email from the new account using Roundcube or the command line:

echo "Subject: Test from newdomain.com
From: [email protected]
To: [email protected]

Test email from new iRedMail domain." | sendmail -t -f [email protected]

Check the mail log for delivery status:

sudo tail -20 /var/log/mail.log | grep newdomain

A successful delivery shows status=sent with dsn=2.0.0. If the email lands in spam, check SPF, DKIM, and DMARC records using MXToolbox.

Managing Existing Accounts

A few common management tasks:

Reset a user password

NEW_HASH=$(doveadm pw -s SSHA512 -p 'NewPassword456')
sudo -u postgres psql -d vmail -c "UPDATE mailbox SET password = '$NEW_HASH' WHERE username = '[email protected]';"

Disable an account without deleting it

sudo -u postgres psql -d vmail -c "UPDATE mailbox SET active = 0 WHERE username = '[email protected]';"

Change mailbox quota

Set the quota to 2048 MB (2 GB):

sudo -u postgres psql -d vmail -c "UPDATE mailbox SET quota = 2048 WHERE username = '[email protected]';"

List all domains and user counts

sudo -u postgres psql -d vmail -c "SELECT d.domain, COUNT(m.username) as users FROM domain d LEFT JOIN mailbox m ON d.domain = m.domain GROUP BY d.domain ORDER BY d.domain;"

All of these operations can also be done through iRedAdmin’s web interface. The CLI approach is faster for bulk changes and easier to automate. For SSL certificate management on your mail server, see our guide on securing iRedMail with Let’s Encrypt.

Related Articles

Email Configure Prometheus Email Alert Notification using Alertmanager Email Zimbra 8.8.15 Open Source Edition’s End of Support CentOS Setup Mail Server on CentOS 8 With Postfix, Dovecot, MySQL and RoundCube Email How Evolving Email Security Practices Have Influenced Modern Cybersecurity

Leave a Comment

Press ESC to close