我正在多台服务器上工作(9台Linux Suse 11和Linux Suse 12)7/9(电子邮件工作)(都在同一个networking下)能够发送电子邮件,如下面的脚本,我需要从shell脚本发送电子邮件到外部域。
mailx -a /opt/script/log/status.log -S smtp=[..].net -r "[email protected]" -s "$HOSTNAME critical_subject " -v "[email protected]" << 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 abc 250 abcHello [..] >>> MAIL FROM:<[email protected]> 250 OK >>> RCPT TO:<[email protected]> 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.
有什么build议? 我可以提供哪些信息?
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
更新 :出于某种原因,我无法从该主机发送电子邮件。 所以我triyng使用7工作机器之一发送电子邮件。 添加了“破”一个我的networking列表的IP,和realy_host作为我想用作中继工作的地址。 在接力赛中,我在自己的networking中join了破门者的地址。 不工作
UPDATE2 :这是客户端的SMTP问题。 我会解决这个问题。
由于此错误出现在RCPT TO:之后,相应的Postfixconfiguration参数是smtpd_recipient_restrictions或smtpd_relay_restrictions ,具体取决于:
在2.10之前的Postfix版本中,中继权限和垃圾邮件阻止的规则被合并在
smtpd_recipient_restrictions下,导致容易出错的configuration。 从Postfix 2.10开始,中继权限规则最好使用smtpd_relay_restrictions来实现,这样smtpd_relay_restrictions下的允许垃圾邮件阻止策略将不再导致允许的邮件中继策略。
你有
smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination
并作为不存在,您的smtpd_relay_restrictions属于默认值:
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination
由于您的脚本没有使用SASL进行身份validation,因此它应该被permit_mynetworks所允许,即它必须在mynetworks列出。 你没有在你的configuration中指定它,但你可以使用postconf | grep "mynetworks = "来检查它 postconf | grep "mynetworks = " 。 当你连接到外部接口而不是localhost( smtp=[..].net )时,它应该包含外部IP。
这可能会影响mynetworks的默认值,导致您的服务器之间的差异:
当Postfix应该“信任”与本地计算机相同的IP子网中的远程SMTP客户端时,指定
mynetworks_style = subnet。 在Linux上,只有使用ifconfig命令指定的接口才能正常工作。
因此,手动指定mynetworks参数可能会更好,例如
mynetworks = 127.0.0.0/8 198.51.100.10/32