在启用收件功能的类别中使用 iRedMail 的别名

:mega: 警告——本主题针对的是非常特定的罕见用例,很可能不是您应该采取的做法。请参阅下方的前两个链接,以获取推荐的设置方案。

前提条件

我在论坛中搜索了关于如何使用 Discourse 搭建工单系统的清晰文章,并找到了一些非常出色的主题:

  1. Configuring incoming email to create new topics or group messages
  2. Use Discourse as a Private Support/Ticket System

问题

不幸的是,我对某些邮件服务器功能不够熟悉,也不知道如何配置对 reply+mailbox@server.comsomerandomcode+mailbox@server.com 的支持。这到底是如何工作的?天哪!:man_facepalming:

我该如何使用分配给不同类别的多个电子邮件地址?如果论坛设置仅支持一个电子邮件地址,这该如何运作?

是的,它完全可以正常工作。基于上述两个教程,我已经理解了入站邮件处理和正确论坛设置的基本原则。如前所述,关键在于邮件服务器的转发功能。

基本的全功能邮件服务器

对于希望搭建零成本邮件服务器的用户,我推荐 iRedMail

  • 这里 是一篇关于在 Ubuntu + Postfix + iRedMail 环境下搭建邮件服务器的文章(英文)
  • 这里 是同样的内容,适用于 CentOS(俄语)

邮件别名

完成默认安装后,您的邮件服务器即可连接到 Discourse。请按照上述步骤 1 和 2,以及接下来关于如何在 iRedMail 中使用邮件别名的步骤进行操作。

例如,您创建了邮箱 master@server.com 以及两个类别:

feature
feature -> internal [private]

您需要在 POP 轮询设置中使用您的邮箱凭证。

连接到您的服务器 Shell,使用 postgres 用户并连接到数据库(我使用的是 postgres):

ssh login@server.com
sudo su - postgres
psql

然后切换到 vmail 模式并创建两个别名

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

下一步,您创建转发规则:

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 或按 CTRL+D 退出

您可以在您喜欢的数据库管理器中检查 aliasesforwardings 这两个表:

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

请注意 active 键,它必须为 1。

检查设置

将邮件别名分配给类别,并从您注册用户的邮箱发送邮件。如有必要,您可以通过以下设置允许匿名邮件发送和自动创建临时用户:

  • 接受来自无账户的匿名用户的邮件(可选,类别设置)
  • 启用临时用户(如果为真,请同时勾选“除非是临时用户则需批准”)
  • POP3 轮询启用 = true
  • POP3 轮询主机(您的主机 FQDN)
  • POP3 轮询端口(通常为 995)
  • POP3 轮询用户名(master@server.com
  • POP3 轮询密码
  • POP3 轮询从服务器删除(可选,我保持禁用状态,以便在邮件客户端中保留原始消息)
  • 记录邮件处理失败(可选,因为您可以在“邮件”选项卡中监控所有事件)
  • 启用入站邮件 = true
  • 入站邮件最低信任级别(我在论坛启动初期使用 0,同时也勾选“在指定天数后清理非活跃用户”)
  • 邮件前缀(可选,如果您的站点标题包含大写名称,它可能会增加自动回复的垃圾邮件评分)
  • 启用转发邮件(可选,在 2.4.0beta2 中仍处于 BETA 阶段,有时无法找到邮件正文)

检查入站邮件

向您的别名发送邮件并进行检查:

/admin/email/received
/admin/email/rejected

现在,所有发送到 master@server.comfeat@server.comstaff@server.com 的邮件都将被放入同一个邮箱 master@server.com。区别在于:发送到 feat@ 的邮件将由 feature 类别处理,而发送到 staff@ 的邮件将由 internal 类别处理。

确保已经出现了新主题!:sunny:

一些说明

  • 即使您将主邮箱 master@ 分配给某个公开或私密类别,所有邮件都会以正确的方式处理(无重复,不泄露隐私)
  • “最小主题标题长度”设置不会影响邮件主题的长度。

The one I recommend is Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver. 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 个赞

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 个赞

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 个赞