{"id":36468,"date":"2019-10-25T22:41:22","date_gmt":"2019-10-25T19:41:22","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=36468"},"modified":"2026-03-28T01:42:23","modified_gmt":"2026-03-27T22:42:23","slug":"add-domain-user-iredmail","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/add-domain-user-iredmail\/","title":{"rendered":"Configure Domains and User Accounts on iRedMail Server"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p><em>Current as of <strong>March 2026<\/strong>. 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).<\/em><\/p>\n\n\n\n<p>If you haven&#8217;t installed iRedMail yet, start with the installation guide for your OS: <a href=\"https:\/\/computingforgeeks.com\/install-iredmail-server-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">Ubuntu 24.04\/22.04<\/a>, <a href=\"https:\/\/computingforgeeks.com\/install-iredmail-server-debian\/\" target=\"_blank\" rel=\"noreferrer noopener\">Debian 12<\/a>, or <a href=\"https:\/\/computingforgeeks.com\/install-and-configure-iredmail-on-rocky-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Rocky Linux \/ AlmaLinux<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add a Mail Domain via iRedAdmin<\/h2>\n\n\n\n<p>Log in to iRedAdmin at <code>https:\/\/mail.example.com\/iredadmin\/<\/code> with your postmaster credentials.<\/p>\n\n\n\n<p>From the dashboard, click <strong>Add<\/strong> in the top menu, then select <strong>Domain<\/strong>. Enter the new domain name (e.g., <code>newdomain.com<\/code>) and configure these settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Domain Name<\/strong>: the bare domain, e.g. <code>newdomain.com<\/code><\/li>\n\n\n\n<li><strong>Mail quota<\/strong>: total storage limit for all mailboxes under this domain (default is 0 for unlimited)<\/li>\n\n\n\n<li><strong>Max number of users<\/strong>: leave at 0 for unlimited, or set a cap<\/li>\n\n\n\n<li><strong>Max number of aliases<\/strong>: same as above<\/li>\n<\/ul>\n\n\n\n<p>Click <strong>Add<\/strong> to save. The domain appears immediately in the Domains list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add a Mail Domain via CLI<\/h2>\n\n\n\n<p>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&#8217;s your backend).<\/p>\n\n\n\n<p>Connect to the vmail database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres psql -d vmail<\/code><\/pre>\n\n\n\n<p>Insert the new domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO domain (domain, transport, active)\nVALUES ('newdomain.com', 'dovecot', 1);<\/code><\/pre>\n\n\n\n<p>Verify the domain was added:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT domain, active FROM domain ORDER BY domain;<\/code><\/pre>\n\n\n\n<p>You should see the new domain listed with <code>active = 1<\/code>.<\/p>\n\n\n\n<p>For MariaDB\/MySQL backends, connect with <code>mysql -u root -p vmail<\/code> and the same SQL works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a User Account via iRedAdmin<\/h2>\n\n\n\n<p>In iRedAdmin, click <strong>Add<\/strong> then <strong>User<\/strong>. Fill in the required fields:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Mail Address<\/strong>: the local part (e.g., <code>john<\/code>) and select the domain from the dropdown<\/li>\n\n\n\n<li><strong>Display Name<\/strong>: the user&#8217;s full name<\/li>\n\n\n\n<li><strong>New password \/ Confirm password<\/strong>: set a strong password<\/li>\n\n\n\n<li><strong>Mailbox quota<\/strong>: per-user storage limit in MB (0 for domain default)<\/li>\n<\/ul>\n\n\n\n<p>Click <strong>Add<\/strong> to create the account. The user can immediately log in to Roundcube at <code>https:\/\/mail.example.com\/mail\/<\/code> or SOGo at <code>https:\/\/mail.example.com\/SOGo\/<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a User Account via CLI<\/h2>\n\n\n\n<p>For scripted user creation, generate a password hash first:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>doveadm pw -s SSHA512 -p 'UserPassword123'<\/code><\/pre>\n\n\n\n<p>This outputs a hash like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{SSHA512}k3x9y7z...<\/code><\/pre>\n\n\n\n<p>Insert the user into the database (PostgreSQL example):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres psql -d vmail<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO mailbox (username, password, name, maildir, quota, domain, active, local_part)\nVALUES (\n  'john@newdomain.com',\n  '{SSHA512}YOUR_HASH_HERE',\n  'John Smith',\n  'newdomain.com\/j\/o\/h\/john-2026.03.28.01.02.03\/',\n  1024,\n  'newdomain.com',\n  1,\n  'john'\n);<\/code><\/pre>\n\n\n\n<p>The <code>maildir<\/code> path follows iRedMail&#8217;s hashed directory layout: <code>domain\/first_char\/second_char\/third_char\/username-timestamp\/<\/code>. The <code>quota<\/code> value is in MB.<\/p>\n\n\n\n<p>Also add the user to the forwardings table so local delivery works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding)\nVALUES ('john@newdomain.com', 'john@newdomain.com', 'newdomain.com', 'newdomain.com', 0);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Set Up DNS Records for the New Domain<\/h2>\n\n\n\n<p>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&#8217;t reach your server and outgoing mail will land in spam.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MX record<\/h3>\n\n\n\n<p>Points email delivery for the new domain to your mail server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>newdomain.com.    IN    MX    10    mail.example.com.<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">SPF record<\/h3>\n\n\n\n<p>Authorizes your mail server to send email for the new domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>newdomain.com.    IN    TXT    \"v=spf1 mx a:mail.example.com -all\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">DKIM record<\/h3>\n\n\n\n<p>iRedMail generates one DKIM key per domain. Generate a key for the new domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo amavisd genrsa \/var\/lib\/dkim\/newdomain.com.pem 2048<\/code><\/pre>\n\n\n\n<p>Add the new domain to the Amavisd DKIM signing configuration. Open <code>\/etc\/amavis\/conf.d\/50-user<\/code> and add the domain to the <code>dkim_key<\/code> list:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/amavis\/conf.d\/50-user<\/code><\/pre>\n\n\n\n<p>Find the <code>dkim_key<\/code> section and add a line for the new domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dkim_key('newdomain.com', 'dkim', '\/var\/lib\/dkim\/newdomain.com.pem');<\/code><\/pre>\n\n\n\n<p>Also add the domain to the <code>@dkim_signature_options_bysender_maps<\/code> array in the same file. Then restart Amavisd:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart amavis<\/code><\/pre>\n\n\n\n<p>Retrieve the public key for DNS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo amavisd showkeys<\/code><\/pre>\n\n\n\n<p>Create a TXT record at <code>dkim._domainkey.newdomain.com<\/code> with the public key from the output. Verify the key propagated:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo amavisd testkeys<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">DMARC record<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>_dmarc.newdomain.com.    IN    TXT    \"v=DMARC1; p=reject; rua=mailto:postmaster@newdomain.com\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Verify DNS propagation<\/h3>\n\n\n\n<p>Check that all records resolve correctly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dig MX newdomain.com +short\ndig TXT newdomain.com +short\ndig TXT dkim._domainkey.newdomain.com +short\ndig TXT _dmarc.newdomain.com +short<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create Email Aliases<\/h2>\n\n\n\n<p>Aliases forward email from one address to another without creating a full mailbox. In iRedAdmin, go to <strong>Add<\/strong> then <strong>Alias<\/strong>. You can also add them via SQL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO alias (address, domain, active)\nVALUES ('info@newdomain.com', 'newdomain.com', 1);\n\nINSERT INTO forwardings (address, forwarding, domain, dest_domain, is_forwarding)\nVALUES ('info@newdomain.com', 'john@newdomain.com', 'newdomain.com', 'newdomain.com', 1);<\/code><\/pre>\n\n\n\n<p>This forwards all mail sent to <code>info@newdomain.com<\/code> to <code>john@newdomain.com<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test the New Domain<\/h2>\n\n\n\n<p>Send a test email from the new account using Roundcube or the command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"Subject: Test from newdomain.com\nFrom: john@newdomain.com\nTo: your-external@gmail.com\n\nTest email from new iRedMail domain.\" | sendmail -t -f john@newdomain.com<\/code><\/pre>\n\n\n\n<p>Check the mail log for delivery status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tail -20 \/var\/log\/mail.log | grep newdomain<\/code><\/pre>\n\n\n\n<p>A successful delivery shows <code>status=sent<\/code> with <code>dsn=2.0.0<\/code>. If the email lands in spam, check SPF, DKIM, and DMARC records using <a href=\"https:\/\/mxtoolbox.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">MXToolbox<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Managing Existing Accounts<\/h2>\n\n\n\n<p>A few common management tasks:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reset a user password<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>NEW_HASH=$(doveadm pw -s SSHA512 -p 'NewPassword456')\nsudo -u postgres psql -d vmail -c \"UPDATE mailbox SET password = '$NEW_HASH' WHERE username = 'john@newdomain.com';\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Disable an account without deleting it<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres psql -d vmail -c \"UPDATE mailbox SET active = 0 WHERE username = 'john@newdomain.com';\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Change mailbox quota<\/h3>\n\n\n\n<p>Set the quota to 2048 MB (2 GB):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres psql -d vmail -c \"UPDATE mailbox SET quota = 2048 WHERE username = 'john@newdomain.com';\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">List all domains and user counts<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>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;\"<\/code><\/pre>\n\n\n\n<p>All of these operations can also be done through iRedAdmin&#8217;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 <a href=\"https:\/\/computingforgeeks.com\/iredmail-letsencrypt-ssl\/\" target=\"_blank\" rel=\"noreferrer noopener\">securing iRedMail with Let&#8217;s Encrypt<\/a>.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>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. Current as of March 2026. Works with &#8230; <a title=\"Configure Domains and User Accounts on iRedMail Server\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/add-domain-user-iredmail\/\" aria-label=\"Read more about Configure Domains and User Accounts on iRedMail Server\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":36461,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,328,50],"tags":[142,16130,16129],"class_list":["post-36468","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-email","category-linux-tutorials","tag-email","tag-iredmail","tag-mail"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/36468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=36468"}],"version-history":[{"count":2,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/36468\/revisions"}],"predecessor-version":[{"id":164919,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/36468\/revisions\/164919"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/36461"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=36468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=36468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=36468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}