# \[OBSOLETE\] Configuring Multiple E-mail Domains on Freedombox

**URL:** https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908
**Category:** Tips and Tricks
**Created:** [January 16, 2024, 4:26pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908 "2024-01-16T16:26:35Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [January 16, 2024, 4:26pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/1 "2024-01-16T16:26:35Z")

</div>

I’m happily using my FBX as an email server for my main domain and all is well. I’ve setup the applications, completed configuration for DKIM, SPF and ARC and have been using my server for well over a year now.

One thing that I wanted to achieve, but couldn’t get my head into how to do it was to add other domains that I own for sending / receiving email. Recently, I’ve found a “hack” to do this. Having come to a point, I wanted to share what I discovered with everyone else.

Now, please take all I’m sharing here with a pinch of salt as I have done all the below through online reading and overall experience over the past year. I am not by any any means proficient and I’m only sharing what just works for me. So, any risks are on you : ) If you have, please do share your comments to make better this thread below.

If you decide to proceed, one thing to get out of the way is that with the below steps, you will not be creating a new e-mail server or a new mailbox. All the domains that you setup will work with the single server and mailbox that comes bundled with FBX. In simple terms, when receiving email, you’ll have only one inbox and all your mail will fall there. Your credentials will be your FBX credentials and all your FBX users (and aliases) will work for the new domains. When sending emails, you’ll see below how to setup DKIM signatures (while configuring ARC). In this respect, you will need to create new “sender identities” in your mail clients and your messages will be signed and sent accordingly.

One downside to this method is, if you’ve properly configured your domain with rDNS (PTR), your other domains will have the same sender IP. Although this is “frowned upon” in means of email security, with DKIM, DMARC, SPF and ARC properly setup, all my emails are making it to Gmail Inbox and I’m getting top scores from all mail testers.

## STEP 0

Now, before getting the hands dirty, it’s important that you have initially setup your mail server server for your primary domain and have correctly configured DKIM, DMARC, SPF and ARC. I’m sharing [this link](https://discuss.freedombox.org/t/solved-email-messages-not-signed-with-dkim/2387) on how to achieve this. If you come across any problems, please post you comments below. I’ve done all my configuration with a single static IP so, I may not have answers to other setups.

Next, connect to your (secondary) domain registrars administration page and set your `A record` in accordance with your static IP. While you’re at it, add an `MX record` as well. For TLS purposes, make sure that you’ve obtained a LetsEncrypt certificate for your new domain on FBX.

Throughout this thread, I’ll be referring to your initial FBX domain as the PRIMARY\_DOMAIN and all other domains that you configure as SECONDARY\_DOMAIN.

| Domain | TTL | Type | Priority | Host/Target/Value |
| --- | --- | --- | --- | --- |
| | 300 | A | | YOUR\_STATIC\_IP |
| | 300 | MX | 10 | SECONDARY\_DOMAIN. |

These setting are crucial for receiving you email. We will be adding more for sending mail, I’ll be sharing them below (in Step 2)

### STEP 1 Receiving Email

Once you’ve configured your DNS serttings as above, edit the `Postfix` main configuration file with the below command.

```auto
sudo nano /etc/postfix/main.cf

```

Towards the end of the file, you’ll notice a `mydestination` variable. Add to the same line (seperated with commas) you new - secondary - domains.

```auto
mydestination = $myhostname, PRIMARY_DOMAIN.com, SECONDARY_DOMAIN.com, localhost.$mydomain, freedombox.local, localhost

```

Save and exit your file, and restart postfix with

```auto
sudo systemctl restart postfix

```

Now you (and all your users) can receive email from your secondary domain.

### STEP 2 Sending Email

Normally, with just the above settings you can technically send emails. Though, if you’ve properly setup your primary domain with the necessary spam-proof settings, there’s a good chance all mail you send from your new domain will be treated as spam.

To overcome this, we’ll be setting up a DKIM signature for your new domain, adding a DMARC and SPF record in your DNS and creating your new ARC file.

**DKIM**

We’ll be having `rspamd` generate a dkim key pair in `/var/lib/rspamd/dkim/`

```auto
sudo su
cd /var/lib/rspamd/dkim/
rspamadm dkim_keygen -s 'dkim' -b 2048 -d seondary_domain.com -k secondary_domain.private > secondary_domain.txt 

```

Once `rspamd` generates the key pair, you’ll be able to see them in the `.txt` file. But before getting to that, lets give ownership of the `dkim` directory to `_rpsamd`

```auto
sudo su
chown -R _rspamd:_rspamd /var/lib/rspamd/dkim
chmod 440 /var/lib/rspamd/dkim/*

```

The `.txt` file contians both your private and public DKIM keys. We’re going to put to use the public key given to us in out DNS settings.  
So,

```auto
cat /var/lib/rspamd/dkim/secondary_domain.txt 

```

should give us something like (your keys will differ)

```auto
 dkim._domainkey IN TXT ( "v=DKIM1; k=rsa; "
	"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2/al5HqXUpe+HUazCr6t9lv2VOZLR369PPB4t+dgljZQvgUsIKoYzfS/w9NagS32xZYxi1dtlDWuRfTU/ahHO2MYzE0zHE4lMfwb6VkNCG+pM6bAkCwc5cFvyRygwxAPEiHAtmtU5b0i9LY25Z/ZWgyBxEWZ0Wf+hLjYHvnvMqewPsduUqKVjDOdUqeBb1VAu3WFErOAGVUYfKqFX"
	"+yfz36Alb7/OMAort8A5Vo5t5k0vxTHzkYYg5KB6tLS8jngrNucGjyNL5+k0ijPs3yT7WpTGL3U3SEa8cX8WvOO1fIpWQz4yyZJJ1Mm62+FskSc7BHjdiMHE64Id/UBDDVjxwIDAQAB"
) ;

```

Punch these values into your DNS as a TXT record.

| Domain | TTL | Type | Priority | Host/Target/Value |
| --- | --- | --- | --- | --- |
| dkim.\_domainkey | 300 | TXT | 10 | “v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2/al5HqXUpe+HUazCr6t9lv2VOZLR369PPB4t+dgljZQvgUsIKoYzfS/w9NagS32xZYxi1dtlDWuRfTU/ahHO2MYzE0zHE4lMfwb6VkNCG+pM6bAkCwc5cFvyRygwxAPEiHAtmtU5b0i9LY25Z/ZWgyBxEWZ0Wf+hLjYHvnvMqewPsduUqKVjDOdUqeBb1VAu3WFErOAGVUYfKqFX” “+yfz36Alb7/OMAort8A5Vo5t5k0vxTHzkYYg5KB6tLS8jngrNucGjyNL5+k0ijPs3yT7WpTGL3U3SEa8cX8WvOO1fIpWQz4yyZJJ1Mm62+FskSc7BHjdiMHE64Id/UBDDVjxwIDAQAB” |

Now, to add your SECONDARY\_DOMAIN to the dkim selectors;

```auto
sudo su
nano /etc/rspamd/local.d/dkim_selectors.map

```

making sure the contents of the file are aligned with below

```auto
{primary_domain.com} dkim
{secondary_domain.com} dkim

```

and, adjusting the signing module with

```auto
nano /etc/rspamd/local.d/dkim_signing.conf

```

_you should have initially onfigured this file when setting up for your primary domain so I2m just adding the last part_

```auto
...
# Domain specific settings
primary_domain.com {

  # Domain name is used as key
  primary_domain.com {

    # Private key path
    path = "/var/lib/rspamd/dkim/primary_domain.com.dkim.key";

    # Selector
    selector = "ds";

  }

}
# Domain specific settings
secondary_domain.com {

  # Domain name is used as key
  secondary_domain {

    # Private key path
    path = "/var/lib/rspamd/dkim/secondary_domain.com.dkim.key";

    # Selector
    selector = "ds";

  }

}

```

After saving and exiting, you may restart `rspamd` here. However, I suggest you continue with ARC setup and then do the restart.

**ARC**

With DKIM setup above, we quickly setup ARC with a single `copy` command

```auto
sudo cp /etc/rspamd/local.d/dkim_signing.conf /etc/rspamd/local.d/arc.conf 

```

And finally, restart `rspamd` with

```auto
sudo systemctl restart rspamd

```

**DMARC and SPF**

Now that things are straight with our server, it’s best to add DMARC and SPF policies to our secondary domain DNS server. Feel free to check online DMARC and SPF generators, but I did my settings with the below.

| Domain | TTL | Type | Priority | Host/Target/Value |
| --- | --- | --- | --- | --- |
| | 300 | TXT | | “v=spf1 mx a ip4:YOUR\_STATIC\_IP -all” |
| \_dmarc | 300 | TXT | | “v=DMARC1; p=none; sp=quarantine; rua=mailto:postmaster@my\_domain.com;” |

Should you wish to recieve DMARC reports to your primary domain mail adress, add the following to your primary domain DNS

| Domain | TTL | Type | Priority | Host/Target/Value |
| --- | --- | --- | --- | --- |
| secondary\_domain.com.\_report.\_dmarc | 300 | TXT | | “v=DMARC1” |

**Identities**

The above should clear you up. Now, create a new identity in your email client with your secondary domain name and do a test drive.

Good luck!

---

<div class="post-metadata">

### Author: ![nbenedek](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/nbenedek/32/1220_2.png) [@nbenedek](https://discuss.freedombox.org/u/nbenedek)
#### Post date: [January 2, 2025, 8:38pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/2 "2025-01-02T20:38:42Z")

</div>

What happens if you authenticate against the secondary domain? Do you not get an SSL mismatch error? Configuring multiple domains with [Postfixadmin](https://github.com/postfixadmin/postfixadmin) requires manual mapping of SSL certificates to each domain with:

```auto
echo "mail.example.com /etc/letsencrypt/live/mail.example.com/privkey.pem /etc/letsencrypt/live/mail.example.com/fullchain.pem" >> /etc/postfix/vmail_ssl.map

echo "mail.example2.com /etc/letsencrypt/live/mail.example2.com/privkey.pem /etc/letsencrypt/live/mail.example2.com/fullchain.pem" >> /etc/postfix/vmail_ssl.map 

postmap -F hash:/etc/postfix/vmail_ssl.map

```

As well as putting the domains in `/etc/dovecot/conf.d/10-ssl.conf`

---

<div class="post-metadata">

### Author: ![Sunil](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/sunil/32/8_2.png) [@Sunil](https://discuss.freedombox.org/u/Sunil)
#### Post date: [January 5, 2025, 1:12am UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/3 "2025-01-05T01:12:48Z")

</div>

[Many changes](https://salsa.debian.org/freedombox-team/freedombox/-/merge_requests/2606) are coming to improve experience with multiple email domains. Specifically, DNS records will be shown for all domains and not just primary domain. DKIM keys will be configured for multiple domains.

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [January 5, 2025, 7:20am UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/4 "2025-01-05T07:20:14Z")

</div>

Sorry I couldn’t respond to this earlier.

This configuration was some cycles ago. From what I recall, I had no issues with authentication despite not having configured `/etc/dovecot/conf.d/10-ssl.conf` or done any mapping. What I did do though was to make sure FBX obtained my letsencrytp certificates prior to setting up any mail accounts (dont know if it means anything).

Now, I don’t use secondary emails for sending. This is because is use a single static IP and my rDNS is mapped to my primary email. As far as I know, my internet service provider cant / wont assign any other.  
However, I do use my FBX for receiving secondary emails. For this, only configuring `/etc/postfix/main.cf` has been enough.

Cheers.

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [January 14, 2025, 1:28pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/5 "2025-01-14T13:28:29Z")

</div>

Hi @Sunil. Would you consider configuring ARC after configuring DKIM?

```auto
cp /etc/rspamd/local.d/dkim_signing.conf /etc/rspamd/local.d/arc.conf 

```

---

<div class="post-metadata">

### Author: ![Sunil](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/sunil/32/8_2.png) [@Sunil](https://discuss.freedombox.org/u/Sunil)
#### Post date: [January 15, 2025, 11:22pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/6 "2025-01-15T23:22:39Z")

</div>

I believe I considered configuring ARC while working on the email app. I will check why it was not added already.

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [January 17, 2025, 5:18pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/7 "2025-01-17T17:18:14Z")

</div>

Thanks @Sunil. Just upgraded to 25.1 and list of Domains in the email app are now visible.

However, I couldn’t understand how we can add / configure domains through plinth. This domain presented in the list are those that I manually added to `/etc/postfix/main.cf`.

Is there any other way to add new domains through plinth?

Thanks.

---

<div class="post-metadata">

### Author: ![Sunil](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/sunil/32/8_2.png) [@Sunil](https://discuss.freedombox.org/u/Sunil)
#### Post date: [January 17, 2025, 7:27pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/8 "2025-01-17T19:27:53Z")

</div>

> [@Ged](#):
>
> However, I couldn’t understand how we can add / configure domains through plinth. This domain presented in the list are those that I manually added to `/etc/postfix/main.cf`.
> 
> Is there any other way to add new domains through plinth?

Currently, one static domain (from Names app), one dynamic domain (from DynamicDNS app), one onion service domain (from Tor app), one Pagekite domain, and one .local domain (derived from hostname in Names app) can be configured on FreedomBox.

Next version of FreedomBox will allow multiple dynamic DNS domains (patch ready) and multiple static domains (I am working on it) to be configured.

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [February 12, 2025, 1:15pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/9 "2025-02-12T13:15:29Z")

</div>

Hi @Sunil,

After the last update to FB 22.1, my rspamd is throwing the following error (mails aren’t getting signed).

```auto
lua; dkim_signing.lua:85: public key for domain mydomain.com/dkim is not found: requested record is not found, skip signing

```

Any way I can help to provide further info/feedback?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![nbenedek](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/nbenedek/32/1220_2.png) [@nbenedek](https://discuss.freedombox.org/u/nbenedek)
#### Post date: [February 15, 2025, 12:19pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/10 "2025-02-15T12:19:08Z")

</div>

This appears to be an issue with name resolution. If this is an internally used domain, it is safe to ignore. Otherwise make sure your FreedomBox can resolve the dkim public key.

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [February 15, 2025, 2:43pm UTC](https://discuss.freedombox.org/t/obsolete-configuring-multiple-e-mail-domains-on-freedombox/2908/11 "2025-02-15T14:43:52Z")

</div>

Hi @nbenedek

It’s not an internally used domain.  
It was working when I had initially set up DKIM (and ARC) as above, but now, emails are not signed by rspamd.

The DNS records and dkim.\_domainkey are all aligned, nothing seems wrong. Would you further clarify/help in how I can make sure my “FreedomBox can resolve the dkim public key”.

Thanks in advance.

EDIT: Although previous attempts to get DKIM signing and configuration of multiple email domains were working, with recent updates to FBX, old configurations started throwing errors and sending mail without signing. After spending some time to solve the issues, I best found that completely uninstalling and re-installing the email suite was the best time saving option.

The FBX team have dome a great job to get things working normally so, I’m adding “obsolete” to the title of the thread.
