由于某种原因,Postfix 正在寻找 /etc/aliases.db,而不是使用 Postgresql db

由于某种原因,Postfix 正在寻找 /etc/aliases.db,而不是使用 Postgresql db

我正在尝试设置我的 Postfix + Devocot + Postgresql。目前只是为了能够以某种方式接收电子邮件并将其保存在文件系统中。

我在 postfix/main.cf 中注释掉了“别名”,但它并没有改变任何东西:

    #  query to find which domains we accept mail for
    virtual_mailbox_domains = pgsql:/etc/postfix/virtual_mailbox_domains.cf

    # query to find which email addresses we accept mail for
    virtual_mailbox_maps = pgsql:/etc/postfix/virtual_mailbox_maps.cf




    ######
    # disable aliases for now, just for testing

    # query to find a user's email aliases
    #virtual_alias_maps = pgsql:/etc/postfix/virtual_alias_maps.cf


    virtual_alias_domains =
    #alias_maps = hash:/etc/aliases
    #alias_database = hash:/etc/aliases

Postfix 的日志:

    localhost postfix/master[30377]: terminating on signal 15
    localhost postfix/postfix-script[30489]: starting the Postfix mail system
    localhost postfix/master[30491]: daemon started -- version 3.3.1, configuration /etc/postfix

    localhost postfix/smtpd[30495]: error: open database /etc/aliases.db: No such file or directory # <----- WHY?????? Why not in Postgresql?

    localhost postfix/smtpd[30495]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
    localhost postfix/smtpd[30495]: connect from sender-of-o51.AAABBBCCC.com[11.22.33.44]
    localhost postfix/trivial-rewrite[30499]: warning: pgsql query failed: fatal error from host localhost: ERROR:  column "value" does not exist?LINE 1: select 1 from domains where value = '[email protected]'?                                    ^?
    localhost postfix/trivial-rewrite[30499]: warning: virtual_mailbox_domains: pgsql:/etc/postfix/virtual_mailbox_domains.cf: table lookup problem
    localhost postfix/trivial-rewrite[30499]: warning: virtual_mailbox_domains lookup failure
    localhost postfix/trivial-rewrite[30499]: warning: virtual_mailbox_domains: pgsql:/etc/postfix/virtual_mailbox_domains.cf: table lookup problem
    localhost postfix/trivial-rewrite[30499]: warning: virtual_mailbox_domains lookup failure
    localhost postfix/trivial-rewrite[30499]: warning: virtual_mailbox_domains: pgsql:/etc/postfix/virtual_mailbox_domains.cf: table lookup problem
    localhost postfix/trivial-rewrite[30499]: warning: virtual_mailbox_domains lookup failure
    localhost postfix/smtpd[30495]: NOQUEUE: reject: RCPT from sender-of-o51.AAABBBCCC.com[11.22.33.44]: 451 4.3.0 <[email protected]>: Temporary lookup failure; from=<[email protected]> to=<mail1@my_postfix_email_server.com> proto=ESMTP helo=<sender-of-o51.AAABBBCCC.com>
    localhost postfix/smtpd[30495]: disconnect from sender-of-o51.AAABBBCCC.com[11.22.33.44] ehlo=2 starttls=1 mail=1 rcpt=0/1 quit=1 commands=5/6

我从我的好电子邮件/gmail 向其发送了一封电子邮件“[电子邮件保护]“。

但是为什么 Postfix 会寻找我的好/外部电邮它是“virtual_domains”表?

发生了什么事?为什么是“ /etc/aliases.db”?如何仅出于测试目的禁用它们?

更新

  $ cat virtual_mailbox_domains.cf 
  user = postfix
  password = aaa
  hosts = localhost
  dbname = postfix_db
  query = select 1 from domains where value = '%s'

  postfix_db=> select * from domains
   id |      name       | description

答案1

打开别名数据库的错误与之无关,但其原因是注释alias_mapsalias_database退出不会清空它们,而是导致使用默认值:

# postconf -d | grep alias_
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases, nis:mail.aliases
. . .

如果您想清空任何配置参数,请在 中明确将其设置为空main.cf

你的实际问题是PostgreSQL 客户端配置或者在您的数据库结构中:

pgsql:/etc/postfix/virtual_mailbox_domains.cf: table lookup problem

以下错误才是您真正应该查看的,因为它指出问题实际上出在您的配置中/etc/postfix/virtual_mailbox_domains.cf,它与您的数据库结构不匹配:

warning: pgsql query failed: fatal error from host localhost: 
   ERROR:  column "value" does not exist?LINE 1: 
   select 1 from domains where value = '[email protected]'?   ^?

了解所使用的查询virtual_mailbox_domains.cf和输出的标题,postfix_db=> select * from domains我们可以发现两个错误。

  • value正如它所说,您的表中没有列domains。 您没有列,而是value有一列name,我猜想该列包含域名。
  • 您正在比较整个电子邮件地址,而不是域名。根据pgsql_table%s被输入的键替换,而被%dpgsql参数中地址的域部分替换query

如果你修复了它们两个,我对可能起作用的结果查询的有根据的猜测是:

query = select 1 from domains where name = '%d'

相关内容