Postfix

Postfix 5.7.1 無法中繼deliverinternalmaild我rectlyd和l一世在和r一世n噸和rn一種l米一種一世ld一世r和C噸l是deliver internal mail directly

  • July 26, 2014

我有以下情況:

  • serverA = RHEL5 使用 Sendmail
  • serverB = RHEL6 使用 Postfix
  • serverC = RHEL6 使用 Postfix
  • gwsmtp = 中繼主機
  • example.com = 域名

當我們從 sendmail 遷移到 postfix 時,我們會遇到一些無法中繼的錯誤。

詳細解釋:

  • 從 serverA 到 serverB 我可以毫無問題地發送電子郵件
  • 從 serverA 到 serverC 我可以毫無問題地發送電子郵件
  • 從 serverB 到 ServerA 我無法發送電子郵件
  • 從 serverB 到 serverC 我無法發送電子郵件

將電子郵件從伺服器 B 發送到伺服器 A 我收到以下退回消息

From MAILER-DAEMON  Tue Jul 22 10:45:24 2014
Return-Path: <>
X-Original-To: root@serverB.example.com
Delivered-To: root@serverB.example.com
Date: Tue, 22 Jul 2014 10:45:24 +0200 (CEST)
From: MAILER-DAEMON@serverB.example.com (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: root@serverB.example.com
Auto-Submitted: auto-replied
Content-Type: multipart/report; report-type=delivery-status;
       boundary="AF55F20DAA.1406018724/serverB"
Status: R

Part 1:
Content-Description: Notification
Content-Type: text/plain; charset=us-ascii

This is the mail system at host serverB.

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

<ch002854@serverA.example.com>: host gwsmtp.example.com[10.39.40.164] said: 550
   5.7.1 Unable to relay (in reply to RCPT TO command)

Part 2:
Content-Description: Delivery report
Content-Type: message/delivery-status


Part 3:
Content-Description: Undelivered Message
Content-Type: message/rfc822

From root@serverB.example.com Tue Jul 22 10:45:09 2014
Return-Path: <root@serverB.example.com>
Date: Tue, 22 Jul 2014 10:45:09 +0200
To: ch002854@serverA.example.com
Subject: test
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@serverB.example.com (root)

我在 serverB 上使用了以下 main.cf 配置

mydomain = example.com
myhostname = serverB
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $myhostname.$mydomain, hpmedtsa, hpmedtsa.$mydomain
relayhost = gwsmtp.$mydomain
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_protocols = all
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
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
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
transport_maps = hash:/etc/postfix/transport

這是我們在 serverA 上的 sendmail makro

divert(-1)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for Red Hat Linux')dnl
OSTYPE(`linux')dnl
define(`SMART_HOST',`gwsmtp.example.com')dnl
LOCAL_NET_CONFIG
R$* < @ $* .$m. > $*    $#smtp $@ $2.$m. $: $1 < @ $2.$m. > $3
define(`confDEF_USER_ID',``8:12'')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
define(`confTO_IDENT', `0')dnl
FEATURE(`no_default_msa',`dnl')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
FEATURE(`accept_unresolvable_domains')dnl
LOCAL_DOMAIN(`localhost.localdomain')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

我們嘗試在 postfix 中使用與 sendmail 中相同的配置。任何幫助將不勝感激。

您應該將 sendmail 的“直接傳遞給同一域中的其他主機”的 hack 遷移到 postfix。

$$ You reported use of smart host in both configurations $$


發送郵件

sendmail.mc

LOCAL_NET_CONFIG
R$* < @ $* .$m. > $*    $#smtp $@ $2.$m. $: $1 < @ $2.$m. > $3

後綴

master.cf

transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport (需要編譯postmap /etc/postfix/transport)

my.domain    :

http://www.postfix.org/postconf.5.html#transport_maps

http://www.postfix.org/transport.5.html

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