LINUX.ORG.RU
решено ФорумAdmin

Postfix игнорирует шаблон bounce_template_file

 


0

1

Ни в какую не хочет принимать измененный шаблон bounce_template_file, просто его игнорирует.

root@postserver:/etc/postfix# postconf -d | grep mail_version
mail_version = 3.4.13

Что было сделано:
В соответсвии с документацией

  1. Был выведен шаблон по умолчанию командой postconf -b, скопирован в файл /etc/postfix/bounce.cf.
  2. Отредактирован в соответствии с документацией, в частности правильно заменены названия шаблонов и в шаблоне о сбое доставки добавлено слово «ENGLISH» (для теста).
failure_template = <<EOF
========
ENGLISH
========

This is the mail system at host $myhostname.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please
send an email to admin@myhost.ru by attaching
this email as a problem report.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system
EOF

delay_template = <<EOF
This is the mail system at host mail.myhost.ru.

####################################################################
# THIS IS A WARNING ONLY.  YOU DO NOT NEED TO RESEND YOUR MESSAGE. #
####################################################################

Your message could not be delivered for more than 0 hour(s).
It will be retried until it is 1 day(s) old.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system
EOF

success_template = <<EOF
This is the mail system at host mail.myhost.ru.

Your message was successfully delivered to the destination(s)
listed below. If the message was delivered to mailbox you will
receive no further notifications. Otherwise you may still receive
notifications of mail delivery errors from other systems.

                   The mail system
EOF

verify_template = <<EOF
This is the mail system at host mail.myhost.ru.

Enclosed is the mail delivery report that you requested.

                   The mail system
EOF
  1. В main.cf добавлен параметр:
bounce_template_file = /etc/postfix/bounce.cf
  1. На файл /etc/postfix/bounce.cf выставлены права 644, владелец root, группа postfix:
root@postserver:/etc/postfix# ls -l | grep bou
-rw-r--r-- 1 root      postfix  1618 Oct 21 20:47 bounce.cf
  1. Postfix перезагружен через systemctl, вывод команды postconf -b /etc/postfix/bounce.cf подтверждает, что мой шаблон принят (c добавлением expanded_ к каждому шаблону):
root@postserver:/etc/postfix# postconf -b /etc/postfix/bounce.cf
expanded_failure_text = <<EOF
========
ENGLISH
========

This is the mail system at host mail.myhost.ru.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please
send an email to admin@myhost.ru by attaching
this email as a problem report.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system 
EOF

expanded_delay_text = <<EOF
This is the mail system at host mail.myhost.ru.

####################################################################
# THIS IS A WARNING ONLY.  YOU DO NOT NEED TO RESEND YOUR MESSAGE. #
####################################################################

Your message could not be delivered for more than 0 hour(s).
It will be retried until it is 1 day(s) old.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system
EOF

expanded_success_text = <<EOF
This is the mail system at host mail.myhost.ru.

Your message was successfully delivered to the destination(s)
listed below. If the message was delivered to mailbox you will
receive no further notifications. Otherwise you may still receive
notifications of mail delivery errors from other systems.

                   The mail system
EOF

expanded_verify_text = <<EOF
This is the mail system at host mail.myhost.ru.

Enclosed is the mail delivery report that you requested.

                   The mail system
EOF

  1. Отправляю письмо с личного ящика на не существующий адрес myhost.ru - получаю ответ о невозможности доставки со стандартным шаблоном, а ожидаю с моим, измененным:
This is the mail system at host mail.xxxxxx.ru.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<petrov1@myhost.ru>: host mx1.myhost.ru[xx.xxx.xxx.xx] said: 550 5.1.1
    <petrov1@myhost.ru>: Recipient address rejected: User unknown in virtual
    mailbox table (in reply to RCPT TO command)

Лог:

Oct 21 21:12:05 postserver postfix/smtpd[11631]: connect from ip-0xx-0xx-101-0xx.static.atnet.ru[xx.xx.xx.xx]
Oct 21 21:12:06 postserver postfix/smtpd[11631]: Anonymous TLS connection established from ip-02xx-0xx-xx-0xx.static.atnet.ru[xx.xx.xx.xx]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
Oct 21 21:12:06 postserver postfix/smtpd[11631]: NOQUEUE: reject: RCPT from ip-0xx-xx-xx-0xx.static.atnet.ru[xx.xx.xx.xx]: 550 5.1.1 <petrov1@myhost.ru>: Recipient address rejected: User unknown in virtual mailbox table; from=<allex@xxxxxx.ru> to=<petrov1@myhost.ru> proto=ESMTP helo=<mail.xxxxxx.ru>
Oct 21 21:12:06 postserver postfix/smtpd[11631]: disconnect from ip-0xx-0xx-xx-0xx.static.atnet.ru[xx.xx.xx.xx] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 rset=1 quit=1 commands=6/8

Я не знаю, что еще можно сделать. Попробовал переименовать bounce.cf в bounce.custom.cf, но это ничего не дает. Измененный шаблон игнорируется.

Мой конфиг main.cf

root@postserver:/etc/postfix# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
anvil_rate_time_unit = 60s
bounce_queue_lifetime = 1d
bounce_template_file = /etc/postfix/bounce.cf
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
compatibility_level = 2
daemon_directory = /usr/lib/postfix/sbin
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
disable_vrfy_command = yes
dovecot_destination_recipient_limit = 1
html_directory = no
inet_interfaces = all
inet_protocols = ipv4
mail_owner = postfix
mailq_path = /usr/bin/mailq
maximal_backoff_time = 10m
maximal_queue_lifetime = 1d
message_size_limit = 27000000
milter_default_action = accept
milter_protocol = 2
minimal_backoff_time = 5m
mydestination = localhost.$mydomain, localhost, $myhostname
mydomain = myhost.ru
myhostname = mail.myhost.ru
mynetworks = 127.0.0.0/8,192.168.0.5
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases
non_smtpd_milters = $smtpd_milters
queue_directory = /var/spool/postfix
queue_run_delay = 2m
relay_domains = mysql:/etc/postfix/mysql/relay_domains.cf
sendmail_path = /usr/sbin/postfix
setgid_group = postdrop
smtp_always_send_ehlo = yes
smtp_tls_ciphers = low
smtp_tls_loglevel = 1
smtp_tls_mandatory_ciphers = low
smtp_tls_mandatory_protocols = !SSLv2,!SSLv3
smtp_tls_note_starttls_offer = yes
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy_maps
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache
smtpd_banner = Hi, the SMTP server $myhostname is ready.
smtpd_client_connection_limit_exceptions = 127.0.0.0/8
smtpd_client_event_limit_exceptions = 127.0.0.0/8
smtpd_client_restrictions = permit_sasl_authenticated, check_client_access hash:/etc/postfix/maps/access_client, check_client_access pcre:/etc/postfix/maps/access_client.pcre, permit_mynetworks
smtpd_data_restrictions = reject_unauth_pipelining, reject_multi_recipient_bounce
smtpd_delay_reject = yes
smtpd_discard_ehlo_keywords = etrn, silent-discard
smtpd_error_sleep_time = 20
smtpd_forbidden_commands = CONNECT GET POST
smtpd_hard_error_limit = 15
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_sasl_authenticated, check_helo_access hash:/etc/postfix/maps/access_helo, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname, reject_unknown_hostname, reject_invalid_hostname
smtpd_milters = inet:127.0.0.1:8891
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/maps/access_recipients, reject_non_fqdn_recipient, reject_unlisted_recipient, reject_unknown_recipient_domain, permit_mynetworks, reject_unauth_destination,
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/dovecot-auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_login_maps = unionmap:{ mysql:/etc/postfix/mysql/sender_verify.cf, pcre:/etc/postfix/maps/sender_verify.pcre}
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/maps/access_sender, reject_authenticated_sender_login_mismatch, reject_non_fqdn_sender, reject_unknown_sender_domain
smtpd_soft_error_limit = 10
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/postfix/certs/fullchain.pem
smtpd_tls_ciphers = low
smtpd_tls_key_file = /etc/postfix/certs/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_ciphers = low
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
soft_bounce = no
spamassassin_destination_recipient_limit = 1
strict_rfc821_envelopes = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf, mysql:/etc/postfix/mysql/virtual_alias_domain_maps.cf
virtual_gid_maps = static:2000
virtual_mailbox_base = /var/mail
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_mailbox_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf
virtual_minimum_uid = 2000
virtual_transport = dovecot
virtual_uid_maps = static:2000
root@postserver:/etc/postfix# postfix check
postfix/postfix-script: warning: not owned by root: /etc/postfix/./fetchmail.conf
postfix/postfix-script: warning: group or other writable: /etc/postfix/./deloldmail.pl
postfix/postfix-script: warning: group or other writable: /etc/postfix/./fetchgen.pl
postfix/postfix-script: warning: symlink leaves directory: /etc/postfix/./makedefs.out

master.cf

root@postserver:/etc/postfix# cat master.cf
#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd
#smtp      inet  n       -       y       -       1       postscreen
#smtpd     pass  -       -       y       -       -       smtpd
#dnsblog   unix  -       -       y       -       0       dnsblog
#tlsproxy  unix  -       -       y       -       0       tlsproxy
# -o content_filter=spamassassin

submission inet n       -       n       -       -       smtpd
 -o syslog_name=postfix/submission
 -o smtpd_tls_security_level=encrypt
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_tls_auth_only=yes
# -o smtpd_sender_restrictions=reject_authenticated_sender_login_mismatch
 -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
 -o smtpd_recipient_restrictions=
 -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING

smtps     inet  n       -       n       -       -       smtpd
 -o syslog_name=postfix/smtps
 -o smtpd_tls_wrappermode=yes
 -o smtpd_sasl_auth_enable=yes
# -o smtpd_sender_restrictions=reject_authenticated_sender_login_mismatch
 -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
 -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
 -o smtpd_relay_restrictions=permit_mynetworks,permit_sasl_authenticated,defer_unauth_destination
 -o milter_macro_daemon_name=ORIGINATING

#628       inet  n       -       y       -       -       qmqpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
        -o syslog_name=postfix/$service_name
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix	-	n	n	-	2	pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot unix - n n - - pipe
 flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

spamassassin unix -     n   n   -   -   pipe
    flags=DRhu user=vmail:vmail argv=/usr/bin/spamc -f -e 
    /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} 



Последнее исправление: allexnew (всего исправлений: 2)

Не понял, вы меняли bounce.cf на сервере, отвечающим за домен @myhost.ru и хотите получить другой ответ на ваше письмо на несуществующий адрес petrov1@myhost.ru?

mky ★★★★★
()
Последнее исправление: mky (всего исправлений: 1)
Ответ на: комментарий от mky

Из документации я понял, что поменять штатные шаблоны ответов нельзя, однако на основе их, через переменную bounce_template_file в main.cf можно прикрутить свои, например, локализованные используя созданный файл bounce.cf.

bounce.cf - не менялся, он создан мною. И да, я ожидаю от postfix, что вместо стандартных ответов, например, о несуществующем адресе будет мой ответ из созданного мною файла-шаблона bounce.cf. Собственно так и расписано в документации.

allexnew
() автор топика
Ответ на: комментарий от allexnew

Блин ну я и дебил. Все вопросы сняты. Я почему-то думал, что мой сервер отправляет хосту, который запросил неправильный адрес.

allexnew
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.