# Use aliases in iRedMail for categories with incoming email feature enabled

**URL:** https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012
**Category:** Sysadmins
**Tags:** how-to
**Created:** [7월 15, 2019, 9:30오후 UTC](https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012 "2019-07-15T21:30:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [7월 15, 2019, 9:30오후 UTC](https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012/1 "2019-07-15T21:30:48Z")

</div>

> 📣 WARNING – this topic is very specific to a particular rare use case and is likely not what you should be doing. Refer to the first two links, below, for the recommended setup.

## Prerequisities

I searched the forum for a clear article on how to setup a ticket system using Discourse and found some brilliant topics:

1. [Configuring incoming email to create new topics or group messages](https://meta.discourse.org/t/start-a-new-topic-via-email-e-mail/62977)
2. [Use Discourse as a Private Support/Ticket System](https://meta.discourse.org/t/how-to-use-discourse-as-a-private-support-ticket-system/72268)

## Questions

Unfortunately, I am not enough familiar with some mail server features, and I don’t know how to configure the support of `reply+mailbox@server.com` or `somerandomcode+mailbox@server.com`. How does it work at all, omg? 🤦‍♂️

How can I use multiple emails assigned to different categories? How does it work if the forum settings support only one email address?

Yes, it works perfectly. Based on those two howtos I understood the principles of incoming emailing and proper forum settings. As previously mentioned, the main in mail server’s forwarding feature.

## Basic fully-functional mail server

For those who want to setup a zero-cost mail server I recommend **iRedMail**

- [Here](https://www.linuxbabe.com/mail-server/ubuntu-16-04-iredmail-server-installation) it is an article to setup a mail server based on ubuntu + postfix + iredmail _in English_
- [here](https://www.dmosk.ru/instruktions.php?object=iredmail-centos7) the same for centos _in Russian_

## Mail aliases

After a default installation, you get mail server ready to connect to Discourse. Follow steps 1 and 2 above and next steps how to use mail aliases in iRedMail.

For example, you created mailbox `master@server.com` and two categories:

```plaintext
feature
feature -> internal [private]

```

You need to use your mailbox credentials in pop polling settings.

Connect to your server shell, use user postgres and connect to the database (I use postgres):

```plaintext
ssh login@server.com
sudo su - postgres
psql

```

Then switch to `vmail` schema and create _two aliases_:

```plaintext
postgres=# \c vmail
postgres=# INSERT INTO alias (address, domain, active)
VALUES ('feat@server.com', 'server.com', 1);

postgres=# INSERT INTO alias (address, domain, active)
VALUES ('staff@server.com', 'server.com', 1);

```

Next step you create forwardings:

```plaintext
postgres=# INSERT INTO forwardings (address, forwarding,
                              domain, dest_domain,
                              is_list, active)
VALUES ('feat@server.com', 'master@server.com',
'server.com', 'server.com', 1, 1);

postgres=# INSERT INTO forwardings (address, forwarding,
                              domain, dest_domain,
                              is_list, active)
VALUES ('staff@server.com', 'master@server.com',
'server.com', 'server.com', 1, 1);

postgres=# \q OR CTRL+D to exit

```

You may check two tables, aliases and forwardings in your favorite DB manager:

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/a/1/a1281e1431a2bc8ba27d621cf0a4e19ccc455fbd.png)

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/6/7/679d40a4ee38b67a94a333b0e9c01fc49ef9f805.png)

Pay attention to active key, it must be 1.

## Check settings

Assign email aliases to categories and sent email from the email of your registered user. If necessary, you may allow anonymous emailing and auto-creating staged users by the following settings:

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://global.discourse-cdn.com/meta/original/3X/e/e/eed205bc7bc2034796373935a60269ee3cd000be.png)

- Accept emails from anonymous users with no accounts (optional, category setting)
- enable staged users (if true, check `approve unless staged` as well )
- pop3 polling enabled = true
- pop3 polling host (your host FQDN)
- pop3 polling port (usually 995)
- pop3 polling username (`master@server.com`)
- pop3 polling password
- pop3 polling delete from server (optional, I leave as disabled to have the original message in my mail client)
- log mail processing failures (optional, because you can monitor all events at Emails tab)
- email in = true
- email in min trust (I use 0 at first after starting my forum, also check `clean up inactive users after days`)
- email prefix (optional, if your site title has CAPSED name, it may add spam score to auto-replies)
- enable forwarded emails (optional, it is still BETA in 2.4.0beta2, sometimes it cannot find email body)

## Check incoming emails

Send emails to your aliases and check:

```plaintext
/admin/email/received
/admin/email/rejected

```

Now all emails sent both to `master@server.com, feat@server.com OR staff@server.com` will put into one mailbox `master@server.com`. The difference is - mails sent to `feat@` will be processed by `feature` category, mails sent to `staff@` will be processed by `internal`.

Ensure that new topics have appeared! ☀

## Some notes

- Even you assign primary email `master@` to some public or private category, all emails will be processed in the right way (no duplicates, no reveal privacy)
- The setting `min topic title length` does not affect the length of email subject.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [7월 15, 2019, 9:45오후 UTC](https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012/2 "2019-07-15T21:45:12Z")

</div>

> [@Ivan\_Rapekas](#):
>
> For those who want to setup a zero-cost mail server I recommend **iRedMail**

The one I recommend is [Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver](https://meta.discourse.org/t/straightforward-direct-delivery-incoming-mail/49487). You don’t need to configure much more than a couple things to set it up and after that you can just use whatever email addresses for groups or categories and it will Just Work.

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [7월 15, 2019, 9:55오후 UTC](https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012/3 "2019-07-15T21:55:42Z")

</div>

Thanks for sharing @pfaffman, I did not find that topic. I am old-school guy, therefore I trust the proven schemes used in production. I just suggest rather fast and stable solution. Also I did not find any mention of word **alias** in relevant search results. So let it be in this howto).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [7월 15, 2019, 10:16오후 UTC](https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012/4 "2019-07-15T22:16:52Z")

</div>

> [@Ivan\_Rapekas](#):
>
> I am old-school guy, therefore I trust the proven schemes used in production.

To each his own, but for handling incoming mail to Discourse a container running Postfix is a pretty proven solution. It’s hard to imagine that iRedMail could be faster or more stable, if only because iRedMail includes a **bunch** of components that you don’t need if all you want to do it get mail delivered to Discourse.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [7월 16, 2019, 1:53오전 UTC](https://meta.discourse.org/t/use-aliases-in-iredmail-for-categories-with-incoming-email-feature-enabled/123012/5 "2019-07-16T01:53:23Z")

</div>

This topic is OK but _highly_ specific to your rather unusual use case. I’m adding a warning to the top of the topic to that effect.
