Networking

此主機上不允許 550 中繼

  • August 4, 2017

我正在使用多個伺服器(9 Linux Suse 11 和 Linux Suse 12)7/9(電子郵件工作)(都在同一個網路下)能夠像下面的腳本一樣發送電子郵件,我需要從 shell 腳本發送電子郵件到外部域。

mailx  -a /opt/script/log/status.log  -S smtp=[..].net -r 
"test@gmail.com" -s "$HOSTNAME critical_subject " -v "mymail@gmail.com" << EOF
Critical Status found during the Monitoring and Control Operation. Please 
check the Attach Log.
EOF

結果我得到了這個:

 Resolving host [..] . . . done.
Connecting to [..]:smtp . . . connected.
220 [..] ESMTP Wed, 02 Aug 2017 09:42:58 +0200
>>> HELO a.b.c
250 a.b.c.Hello [..]
>>> MAIL FROM:<test@gmail.com>
250 OK
>>> RCPT TO:<mymail@gmail.com>
550 relay is not permitted on this host.
smtp-server: 550 relay is not permitted on this host.
"/root/dead.letter" 102/5133
. . . message not sent.

有什麼建議嗎?我可以提供哪些資訊?

main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix

mail_owner = postfix


# REJECTING MAIL FOR UNKNOWN LOCAL USERS
unknown_local_recipient_reject_code = 550

smtpd_banner = $myhostname ESMTP


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
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq

setgid_group = maildrop

html_directory = /usr/share/doc/packages/postfix-doc/html
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/packages/postfix-doc/samples
readme_directory = /usr/share/doc/packages/postfix-doc/README_FILES

biff = no
content_filter = 
delay_warning_time = 1h
disable_dns_lookups = no
disable_mime_output_conversion = no
disable_vrfy_command = yes
inet_interfaces = localhost
inet_protocols = all
masquerade_classes = envelope_sender, header_sender, header_recipient
masquerade_domains = 
masquerade_exceptions = root
mydestination = $myhostname, localhost.$mydomain
myhostname = domain.domain.net
mynetworks_style = subnet
mynetworks= [list of ip in subnet form]
relayhost = relay_adress

alias_maps = hash:/etc/aliases
canonical_maps = hash:/etc/postfix/canonical
relocated_maps = hash:/etc/postfix/relocated
sender_canonical_maps = hash:/etc/postfix/sender_canonical
transport_maps = hash:/etc/postfix/transport
mail_spool_directory = /var/mail
message_strip_characters = \0
defer_transports = 
mailbox_command = 
mailbox_transport = 
mailbox_size_limit = 0
message_size_limit = 0
strict_8bitmime = no
strict_rfc821_envelopes = no
smtpd_delay_reject = yes
smtpd_helo_required = no

smtpd_client_restrictions = 

smtpd_helo_restrictions = 

smtpd_sender_restrictions = hash:/etc/postfix/access

smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination


############################################################
# SASL stuff
############################################################
smtp_sasl_auth_enable = no
smtp_sasl_security_options = 
smtp_sasl_password_maps = 
smtpd_sasl_auth_enable = no
############################################################
# TLS stuff
############################################################
relay_clientcerts = 

smtp_use_tls = no
smtp_enforce_tls = no
smtp_tls_CAfile = 
smtp_tls_CApath = 
smtp_tls_cert_file = 
smtp_tls_key_file = 
smtp_tls_session_cache_database = 

smtpd_use_tls = no
smtpd_tls_CAfile = 
smtpd_tls_CApath = 
smtpd_tls_cert_file = 
smtpd_tls_key_file = 
smtpd_tls_ask_ccert = no
smtpd_tls_received_header = no

############################################################
# Start MySQL from postfixwiki.org
############################################################
relay_domains = $mydestination, hash:/etc/postfix/relay
virtual_alias_domains = hash:/etc/postfix/virtual
virtual_alias_maps = hash:/etc/postfix/virtual

更新:由於某種原因,我無法從該主機發送電子郵件。因此,我嘗試使用 7 台工作機器中的一台來發送電子郵件。添加在“損壞”的一個 mynetworks ip 列表中,並將 realy_host 作為我想用作中繼的工作地址。在中繼一中,我在 mynetworks 中添加了損壞的地址。不工作

UPDATE2:這是客戶客戶端的 SMTP 問題。我會關閉這個問題。

由於此錯誤出現在 之後RCPT TO:,因此相應的 Postfix 配置參數是smtpd_recipient_restrictionssmtpd_relay_restrictions,具體取決於:

在 2.10 之前的 Postfix 版本中,中繼權限和垃圾郵件攔截的規則組合在 下smtpd_recipient_restrictions,導致配置容易出錯。從 Postfix 2.10 開始,中繼權限規則最好使用 實現 smtpd_relay_restrictions,這樣允許的垃圾郵件攔截策略smtpd_recipient_restrictions將不再導致允許的郵件中繼策略。

你有

smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination

並且作為不存在的,你smtpd_relay_restrictions屬於預設:

smtpd_relay_restrictions =
   permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination

由於您的腳本未使用 SASL 進行身份驗證,因此它應該被 允許permit_mynetworks,即它必須列在mynetworks. 您尚未在配置中指定它,但您可以使用postconf | grep "mynetworks = ". 當您連接到外部介面而不是 localhost ( smtp=[..].net) 時,它應該包括外部 IP。

這可能會影響 的預設值mynetworks,從而導致您的伺服器之間存在差異:

指定mynetworks_style = subnetPostfix 何時應該“信任”與本地機器相同 IP 子網中的遠端 SMTP 客戶端。在 Linux 上,這僅適用於使用 ifconfig命令指定的介面。

因此,最好mynetworks手動指定參數,例如

mynetworks = 127.0.0.0/8 198.51.100.10/32

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