How to use aliases in iRedMail for categories with incoming email feature enabled

:mega: 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. Start a New Topic via Email ✉
  2. How to Use Discourse as a Private Support/Ticket System

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? :man_facepalming:

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 it is an article to setup a mail server based on ubuntu + postfix + iredmail in English
  • here 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:

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):

ssh login@server.com
sudo su - postgres
psql

Then switch to vmail schema and create two aliases:

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:

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:

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

  • 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:

/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! :sunny:

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.

The one I recommend is Straightforward direct-delivery incoming mail. 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.

2 Likes

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).

1 Like

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.

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.

4 Likes