linux – Postfix客户端主机被拒绝

前端之家收集整理的这篇文章主要介绍了linux – Postfix客户端主机被拒绝前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Ubuntu 12.04上设置了Postfix Courier Roundcube,但是当我尝试使用Roundcube发送电子邮件时,收到以下错误

/var/log/mail.log:

  1. Dec 30 20:54:35 server postfix/smtpd[31465]: connect from localhost[127.0.0.1]
  2. Dec 30 20:54:35 server postfix/smtpd[31465]: Anonymous TLS connection established from localhost[127.0.0.1]: TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)
  3. Dec 30 20:54:35 server postfix/smtpd[31465]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 554 5.7.1 <localhost[127.0.0.1]>: Client host rejected: Access denied; from=<sender@mydomain.net> to=<receiver@gmail.com> proto=ESMTP helo=<mail.mydomain.net>
  4. Dec 30 20:54:35 server postfix/smtpd[31465]: disconnect from localhost[127.0.0.1]

根据我的设置,不确定这是怎么回事:

/etc/postfix/main.cf:

  1. # Debian specific: Specifying a file name will cause the first
  2. # line of that file to be used as the name. The Debian default
  3. # is /etc/mailname.
  4. #myorigin = /etc/mailname
  5.  
  6. smtpd_banner = $myhostname ESMTP $mail_name
  7. biff = no
  8.  
  9. # appending .domain is the MUA's job.
  10. append_dot_mydomain = no
  11.  
  12. # Uncomment the next line to generate "delayed mail" warnings
  13. #delay_warning_time = 4h
  14.  
  15. readme_directory = no
  16.  
  17. # TLS parameters
  18. smtp_tls_security_level = may
  19. smtpd_tls_security_level = may
  20. smtp_tls_note_starttls_offer = yes
  21. smtpd_tls_loglevel = 1
  22. smtpd_tls_received_header = yes
  23. smtpd_tls_session_cache_timeout = 3600s
  24. tls_random_source = dev:/dev/urandom
  25. smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
  26. smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
  27. # smtpd_use_tls=yes
  28. # smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
  29. # smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
  30. smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
  31.  
  32. #SASL
  33. smtpd_sasl_auth_enable = yes
  34. broken_sasl_auth_clients = no
  35. smtpd_sasl_security_options = noanonymous
  36. smtpd_sasl_local_domain =
  37.  
  38. # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
  39. # information on enabling SSL in the smtp client.
  40.  
  41. myhostname = server.mydomain.net
  42. alias_maps = hash:/etc/aliases
  43. alias_database = hash:/etc/aliases
  44. myorigin = mydomain.net
  45. mydestination = mail.mydomain.net,mydomain.net,localhost.mydomain.net,localhost
  46. #mydestination =
  47. relayhost =
  48. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  49. mailBox_command = procmail -a "$EXTENSION"
  50. mailBox_size_limit = 0
  51. recipient_delimiter = +
  52. inet_interfaces = all
  53. mynetworks_style = host
  54.  
  55. masquerade_domains = mail.mydomain.net mydomain.net !sub.dyndomain.com
  56. masquerade_exceptions = root
  57.  
  58. local_recipient_maps =
  59. mydestination =
  60. delay_warning_time = 4h
  61. unknown_local_recipient_reject_code = 450
  62. maximal_queue_lifetime = 7d
  63. minimal_backoff_time = 1000s
  64. maximal_backoff_time = 8000s
  65. smtp_helo_timeout = 60s
  66. smtpd_recipient_limit = 16
  67. smtpd_soft_error_limit = 3
  68. smtpd_hard_error_limit = 12
  69.  
  70. smtpd_helo_restrictions = permit_mynetworks,warn_if_reject reject_non_fqdn_hostname,reject_invalid_hostname,permit
  71. smtpd_sender_restrictions = permit_sasl_authenticated,permit_mynetworks,warn_if_reject reject_non_fqdn_sender,reject_unknown_sender_domain,reject_unauth_pipelining,permit
  72. smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org,reject_rbl_client blackholes.easynet.nl
  73. smtpd_recipient_restrictions = reject_unauth_pipelining,permit_sasl_authenticated,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_destination,check_policy_service inet:127.0.0.1:10023,permit
  74. smtpd_data_restrictions = reject_unauth_pipelining
  75.  
  76. smtpd_helo_required = yes
  77. smtpd_delay_reject = yes
  78. disable_vrfy_command = yes
  79.  
  80. alias_maps = hash:/etc/postfix/aliases
  81. alias_database = hash:/etc/postfix/aliases
  82. virtual_mailBox_base = /var/spool/mail/virtual
  83. virtual_mailBox_maps = MysqL:/etc/postfix/MysqL_mailBox.cf
  84. virtual_alias_maps = MysqL:/etc/postfix/MysqL_alias.cf
  85. virtual_mailBox_domains = MysqL:/etc/postfix/MysqL_domains.cf
  86.  
  87. virtual_uid_maps = static:5000
  88. virtual_gid_maps = static:5000
  89.  
  90. content_filter = amavis:[127.0.0.1]:10024

/etc/postfix/master.cf:

  1. # Postfix master process configuration file. For details on the format
  2. # of the file,see the master(5) manual page (command: "man 5 master").
  3. #
  4. # Do not forget to execute "postfix reload" after editing this file.
  5. #
  6. # ==========================================================================
  7. # service type private unpriv chroot wakeup maxproc command + args
  8. # (yes) (yes) (yes) (never) (100)
  9. # ==========================================================================
  10. smtp inet n - - - - smtpd
  11. #smtp inet n - - - 1 postscreen
  12. #smtpd pass - - - - - smtpd
  13. #dnsblog unix - - - - 0 dnsblog
  14. #tlsproxy unix - - - - 0 tlsproxy
  15.  
  16. submission inet n - n - - smtpd
  17. -o smtpd_sasl_auth_enable=yes
  18. -o smtpd_tls_auth_only=yes
  19. -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  20. -o smtpd_sasl_security_options=noanonymous,noplaintext
  21. -o smtpd_sasl_tls_security_options=noanonymous
  22. # -o syslog_name=postfix/submission
  23. # -o smtpd_tls_security_level=encrypt
  24. # -o smtpd_sasl_auth_enable=yes
  25. # -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  26. # -o milter_macro_daemon_name=ORIGINATING
  27. smtps inet n - - - - smtpd
  28. -o smtpd_tls_wrappermode=yes
  29. -o smtpd_sasl_auth_enable=yes
  30. -o smtpd_tls_auth_only=yes
  31. -o smtpd_client_restrictions=permit_sasl_authenticated,noplaintext
  32. -o smtpd_sasl_tls_security_options=noanonymous
  33. # -o syslog_name=postfix/smtps
  34. # -o smtpd_tls_wrappermode=yes
  35. # -o smtpd_sasl_auth_enable=yes
  36. # -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  37. # -o milter_macro_daemon_name=ORIGINATING
  38. #628 inet n - - - - qmqpd
  39. pickup fifo n - - 60 1 pickup
  40. -o content_filter=
  41. -o receive_override_options=no_header_body_checks
  42. cleanup unix n - - - 0 cleanup
  43. qmgr fifo n - n 300 1 qmgr
  44. #qmgr fifo n - n 300 1 oqmgr
  45. tlsmgr unix - - - 1000? 1 tlsmgr
  46. rewrite unix - - - - - trivial-rewrite
  47. bounce unix - - - - 0 bounce
  48. defer unix - - - - 0 bounce
  49. trace unix - - - - 0 bounce
  50. verify unix - - - - 1 verify
  51. flush unix n - - 1000? 0 flush
  52. proxymap unix - - n - - proxymap
  53. proxywrite unix - - n - 1 proxymap
  54. smtp unix - - - - - smtp
  55. relay unix - - - - - smtp
  56. # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
  57. showq unix n - - - - showq
  58. error unix - - - - - error
  59. retry unix - - - - - error
  60. discard unix - - - - - discard
  61. local unix - n n - - local
  62. virtual unix - n n - - virtual
  63. lmtp unix - - - - - lmtp
  64. anvil unix - - - - 1 anvil
  65. scache unix - - - - 1 scache
  66. #
  67. # ====================================================================
  68. # Interfaces to non-Postfix software. Be sure to examine the manual
  69. # pages of the non-Postfix software to find out what options it wants.
  70. #
  71. # Many of the following services use the Postfix pipe(8) delivery
  72. # agent. See the pipe(8) man page for information about ${recipient}
  73. # and other message envelope options.
  74. # ====================================================================
  75. #
  76. # maildrop. See the Postfix MAILDROP_README file for details.
  77. # Also specify in main.cf: maildrop_destination_recipient_limit=1
  78. #
  79. maildrop unix - n n - - pipe
  80. flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
  81. #
  82. # ====================================================================
  83. #
  84. # Recent Cyrus versions can use the existing "lmtp" master.cf entry.
  85. #
  86. # Specify in cyrus.conf:
  87. # lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
  88. #
  89. # Specify in main.cf one or more of the following:
  90. # mailBox_transport = lmtp:inet:localhost
  91. # virtual_transport = lmtp:inet:localhost
  92. #
  93. # ====================================================================
  94. #
  95. # Cyrus 2.1.5 (Amos Gouaux)
  96. # Also specify in main.cf: cyrus_destination_recipient_limit=1
  97. #
  98. #cyrus unix - n n - - pipe
  99. # user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
  100. #
  101. # ====================================================================
  102. # Old example of delivery via Cyrus.
  103. #
  104. #old-cyrus unix - n n - - pipe
  105. # flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
  106. #
  107. # ====================================================================
  108. #
  109. # See the Postfix UUCP_README file for configuration details.
  110. #
  111. uucp unix - n n - - pipe
  112. flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
  113. #
  114. # Other external delivery methods.
  115. #
  116. ifmail unix - n n - - pipe
  117. flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
  118. bsmtp unix - n n - - pipe
  119. flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
  120. scalemail-backend unix - n n - 2 pipe
  121. flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
  122. mailman unix - n n - - pipe
  123. flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  124. ${nexthop} ${user}
  125.  
  126. amavis unix - - - - 2 smtp
  127. -o smtp_data_done_timeout=1200
  128. -o smtp_send_xforward_command=yes
  129. -o disable_dns_lookups=yes
  130. -o max_use=20
  131.  
  132. 127.0.0.1:10025 inet n - - - - smtpd
  133. -o content_filter=
  134. -o local_recipient_maps=
  135. -o relay_recipient_maps=
  136. -o smtpd_restriction_classes=
  137. -o smtpd_delay_reject=no
  138. -o smtpd_client_restrictions=permit_mynetworks,reject
  139. -o smtpd_helo_restrictions= -o smtpd_sender_restrictions=
  140. -o smtpd_recipient_restrictions=permit_mynetworks,reject
  141. -o smtpd_data_restrictions=reject_unauth_pipelining
  142. -o smtpd_end_of_data_restrictions=
  143. -o mynetworks=127.0.0.0/8
  144. -o smtpd_error_sleep_time=0
  145. -o smtpd_soft_error_limit=1001
  146. -o smtpd_hard_error_limit=1000
  147. -o smtpd_client_connection_count_limit=0
  148. -o smtpd_client_connection_rate_limit=0
  149. -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks

/etc/roundcube/main.inc.PHP的相关部分

  1. // ----------------------------------
  2. // SMTP
  3. // ----------------------------------
  4.  
  5. // SMTP server host (for sending mails).
  6. // To use SSL/TLS connection,enter hostname with prefix ssl:// or tls://
  7. // If left blank,the PHP mail() function is used
  8. // Supported replacement variables:
  9. // %h - user's IMAP hostname
  10. // %n - http hostname ($_SERVER['SERVER_NAME'])
  11. // %d - domain (http hostname without the first part)
  12. // %z - IMAP domain (IMAP hostname without the first part)
  13. // For example %n = mail.domain.tld,%d = domain.tld
  14.  
  15. $rcmail_config['smtp_server'] = 'ssl://127.0.0.1';
  16.  
  17. // SMTP port (default is 25; 465 for SSL)
  18. $rcmail_config['smtp_port'] = 465;
  19.  
  20. // SMTP username (if required) if you use %u as the username Roundcube
  21. // will use the current username for login
  22. $rcmail_config['smtp_user'] = '';
  23.  
  24. // SMTP password (if required) if you use %p as the password Roundcube
  25. // will use the current user's password for login
  26. $rcmail_config['smtp_pass'] = '';
  27.  
  28. // SMTP AUTH type (DIGEST-MD5,CRAM-MD5,LOGIN,PLAIN or empty to use
  29. // best server supported one)
  30. $rcmail_config['smtp_auth_type'] = '';
  31.  
  32. // Optional SMTP authentication identifier to be used as authorization proxy
  33. $rcmail_config['smtp_auth_cid'] = null;
  34.  
  35. // Optional SMTP authentication password to be used for smtp_auth_cid
  36. $rcmail_config['smtp_auth_pw'] = null;
  37.  
  38. // SMTP HELO host
  39. // Hostname to give to the remote server for SMTP 'HELO' or 'EHLO' messages
  40. // Leave this blank and you will get the server variable 'server_name' or
  41. // localhost if that isn't defined.
  42. $rcmail_config['smtp_helo_host'] = 'mail.mydomain.net';
  43.  
  44. // SMTP connection timeout,in seconds. Default: 0 (no limit)
  45. $rcmail_config['smtp_timeout'] = 0;

有任何想法吗?我觉得我在这里走到了尽头.

解决方法

您定义了smtpd_sasl_security_options = noanonymous(这也是默认值).
在你的圆形立方体配置线
  1. $rcmail_config['smtp_server'] = 'ssl://127.0.0.1';

定义使用ssl.
对于匿名ssl连接被拒绝,您必须提供连接的用户名和密码.
但你没有定义:

  1. // SMTP username (if required) if you use %u as the. username Roundcube
  2. // will use the current username for login
  3. $rcmail_config['smtp_user'] = '';
  4.  
  5. // SMTP password (if required) if you use %p as the password Roundcube
  6. // will use the current user's password for login
  7. $rcmail_config['smtp_pass'] = '';

猜你在找的Linux相关文章