Назад | Перейти на главную страницу

Postgresql Postfix: подключиться к серверу pgsql unix: / var / run / postgresql: не удалось подключиться к серверу

Я пытаюсь использовать Postfix для аутентификации в базе данных postgresql на экспериментальном сервере debian 8. Моя конфигурация postgresql следующая:

Файл /etc/postgresql/9.4/main/pg_hba.conf:

# Database administrative login by Unix domain socket
local   all             postgres                                peer 
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
#local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.\
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
local    mail        all                 ident map=mailmap
local   all              all                                     peer

Файл /etc/postgresql/9.4/main/pg_ident.conf:

 mailmap         dovecot                 mailreader
 mailmap         postfix                 mailreader
 mailmap         root                    mailreader

Моя конфигурация Postfix содержит следующие файлы:

В /etc/postfix/main.cf имеет следующую конфигурацию:

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/pcmagas.tk/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/pcmagas.tk/privkey.pem

smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
# The path is relative to $queue_directory:
#   # postconf |grep queue_directory
#   queue_directory = /var/spool/postfix
smtpd_sasl_path = private/auth
# Do not accept SASL authentication over unencrypted connections
smtpd_tls_auth_only = yes

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases


myhostname = mail.pcmagas.tk
myorigin = /etc/mailname
mydestination = mail.pcmagas.tk,localhost

relayhost = [mail.smtp2go.com]:2525
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

#virtual mailbox
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = pcmagas.tk  
virtual_mailbox_maps = pgsql:/etc/postfix/pgsql-boxes.cf
virtual_alias_maps = pgsql:/etc/postfix/pgsql-aliases.cf

В /etc/postfix/pgsql-boxes.cf имеет следующее содержание:

user=mailreader
dbname=mail
table=users
select_field=email
where_field=email
hosts=unix:/var/run/postgresql

В /etc/postfix/pgsql-aliases.cf имеет это содержание:

user=mailreader
dbname=mail
table=aliases
select_field=alias
where_field=email
hosts=unix:/var/run/postgresql

Так же ls -l /var/run/postgresql/ дает следующее:

drwxr-s--- 2 postgres postgres 120 Ιούν 29 18:06 9.4-main.pg_stat_tmp
-rw-r--r-- 1 postgres postgres   4 Ιούν 29 17:20 9.4-main.pid

Когда я пытаюсь отправить местную почту через sendemail команда выводит следующее сообщение:

29 июня 18:08:42 mailservertest sendemail [1189]: ВНИМАНИЕ => Аутентификация не> поддерживается удаленным SMTP-сервером! 29 июня 18:08:42 mailservertest sendemail [1189]: WARNING => Получатель был отклонен почтовым сервером, следующая ошибка: 29 июня 18:08:42 mailservertest sendemail [1189]: WARNING => Получено: 451 4.3.0 : Временная ошибка поиска 29 июня 18:08:42 mailservertest sendemail [1189]: ERROR => Выход. Почтовый сервер не принял ни одного получателя для доставки.

И /var/log/mail.log файл имеет следующие журналы:

29 июня 18:10:38 MailserverTest postfix / postscreen [1202]: CONNECT from [:: 1]: 32932 to [:: 1]: 25 Jun 29 18:10:38 MailserverTest postfix / postscreen [1202]: БЕЛЫЙ СПИСОК [: : 1]: 32932 29 июня, 18:10:38 MailserverTest postfix / smtpd [1203]: подключение с локального хоста [:: 1] 29 июня 18:10:38 MailserverTest postfix / trivial-rewrite [1205]: предупреждение: подключиться к pgsql сервер unix: / var / run / postgresql: не удалось подключиться к серверу: нет такого файла или каталога ?? Работает ли сервер локально и принимает ?? соединения на сокете домена Unix "/var/run/postgresql/.s.PGSQL. 5432 "?? 29 июня, 18:10:38 MailserverTest postfix / trivial-rewrite [1205]: предупреждение: pgsql: /etc/postfix/pgsql-aliases.cf: проблема поиска в таблице 29 июня 18:10:38 MailserverTest postfix / trivial-rewrite [1205 ]: предупреждение: ошибка поиска virtual_alias_domains 29 июня 18:10:38 MailserverTest postfix / trivial-rewrite [1205]: предупреждение: pgsql: /etc/postfix/pgsql-aliases.cf: проблема поиска в таблице 29 июня 18:10:38 MailserverTest postfix / trivial-rewrite [1205]: предупреждение: ошибка поиска virtual_alias_domains 29 июня 18:10:38 MailserverTest postfix / smtpd [1203]: NOQUEUE: reject: RCPT from localhost [:: 1]: 451 4.3.0: временный сбой поиска ; from = to = proto = ESMTP helo = 29 июня 18:10:38 MailserverTest postfix / smtpd [1203]: потеряно соединение после RCPT от localhost [:: 1] 29 июня 18:10:38 MailserverTest postfix / smtpd [1203]: отключиться от localhost [:: 1]

Также в базе данных, которую я использую, есть следующие таблицы:

 Schema |  Name   | Type  |   Owner    
--------+---------+-------+------------
 public | aliases | table | mailreader
 public | users   | table | mailreader

И каждая таблица имеет следующую схему:

mail=> \d users
                Table "public.users"
  Column  |           Type           |   Modifiers   
----------+--------------------------+---------------
 email    | text                     | not null
 password | text                     | not null
 maildir  | text                     | not null
 created  | timestamp with time zone | default now()

mail=> \d aliases
  Table "public.aliases"
 Column | Type | Modifiers 
--------+------+-----------
 alias  | text | not null
 email  | text | not null

Также postgresql прослушивает сокет unix:

netstat -xlnp | grep postgresql
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
unix  2      [ ACC ]     STREAM     LISTENING     11651    -                   /var/run/postgresql/.s.PGSQL.5432

У вас есть идеи, ребята, почему я получаю эти ошибки и как их исправить? А

В конце концов, мне нужно было переключиться на аутентификацию хоста, которая работала как шарм:

в pg_hba.conf измените строку на: host mail mailreader 127.0.0.1/32 ident map = mailmap

Также в postgresql через sudo -u postgres psql (обычно) выполните следующую команду, чтобы установить пароль для пользователя mailreader:

ALTER USER mailreader WITH PASSWORD '^password_here^'

Тогда как на /etc/postfix/pgsql-boxes.cf и /etc/postfix/pgsql-aliases.cf изменить

hosts=unix:/var/run/postgresql 

линия в

hosts=localhost

Также установите password в обоих файлах, упомянутых выше, вот так:

password=^put the password here^

Вы должны определить программу чтения почты в pg_hba.conf.