Linux

Postfix 出於某種原因正在尋找 /etc/aliases.db 而不是使用 Postgresql db

  • May 27, 2018

我正在嘗試設置我的 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

後綴日誌:

   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 = 'my_original_good_email@gmail.com'?                                    ^?
   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 <my_original_good_email@gmail.com>: Temporary lookup failure; from=<my_original_good_email@gmail.com> 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“my_original_good_email@gmail.com”向它發送了一封電子郵件。

但是為什麼 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

打開別名數據庫的錯誤是無關的,但原因是註釋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 = 'my_original_good_email@gmail.com'?   ^?

知道使用的查詢virtual_mailbox_domains.cf和輸出中的標題,postfix_db=> select * from domains我們可以發現兩個錯誤。

  • value正如它所說,您的 table中沒有列domains。而不是列value,你有一個name我想有域名的列。
  • 您正在比較整個電子郵件地址而不是域。根據pgsql_table%s替換為輸入鍵,而%d被替換為 pgsql 參數內地址的域部分query

如果你同時修復它們,我對可能有效的結果查詢的有根據的猜測是:

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

引用自:https://serverfault.com/questions/913951