Debian

Postfix 郵件伺服器 & dovecot 可以發送但不能接收

  • July 30, 2020

今天我用這個教程創建了一個郵件伺服器:https ://www.milbako.com/e-mail-avec-postfix-dovecot-et-mysql/ 我可以發送郵件(被檢測為垃圾郵件,但它有效),但如果我用我的gmail地址給我發了一封電子郵件,它不會工作……

這是我的 main.cf 文件:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2


# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/cpmtech.fr-0001/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/cpmtech.fr-0001/privkey.pem
smtpd_use_tls=yes
smtpd_tls_auth_only = yes
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous

# Authentication
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

# Voir /usr/share/doc/postfix/TLS_README.gz dans le paquet postfix-doc pour plus de détails.
# informations sur l’activation de SSL dans le client smtp.

# Restrictions
smtpd_helo_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_invalid_helo_hostname,
reject_non_fqdn_helo_hostname
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
reject_unlisted_recipient,
reject_unauth_destination
smtpd_sender_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_sender,
reject_unknown_sender_domain
smtpd_relay_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
defer_unauth_destination

# Voir /usr/share/doc/postfix/TLS_README.gz dans le paquet postfix-doc pour plus de détails.
# informations sur l’activation de SSL dans le client smtp.

myhostname = cpmtech.fr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydomain = cpmtech.fr
myorigin = $mydomain
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

# Remettre la livraison locale au LMTP de Dovecot et lui dire où stocker le courrier
virtual_transport = dovecot

# Domaines virtuels, utilisateurs et alias
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf,
mysql:/etc/postfix/mysql-virtual-email2email.cf

# Encore plus de restrictions et de paramètres MTA
disable_vrfy_command = yes
strict_rfc821_envelopes = yes
#smtpd_etrn_restrictions = reject
#smtpd_reject_unlisted_sender = yes
#smtpd_reject_unlisted_recipient = yes
smtpd_delay_reject = yes
smtpd_helo_required = yes
smtp_always_send_ehlo = yes
#smtpd_hard_error_limit = 1
smtpd_timeout = 30s
smtp_helo_timeout = 15s
smtp_rcpt_timeout = 15s
smtpd_recipient_limit = 40
minimal_backoff_time = 180s
maximal_backoff_time = 3h

# Codes de rejet de réponse
invalid_hostname_reject_code = 550
non_fqdn_reject_code = 550
unknown_address_reject_code = 550
unknown_client_reject_code = 550
unknown_hostname_reject_code = 550
unverified_recipient_reject_code = 550
unverified_sender_reject_code = 550

#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
#myhostname = cpmtech.fr
#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
#mydestination = cpmtech.fr, localhost.cpmtech.fr, localhost
#mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
#mailbox_size_limit = 0
#recipient_delimiter = +
#inet_protocols = all
#myorigin = /etc/mailname
#mynetworks_style = subnet
#recipient_canonical_maps =
#relayhost = 
#inet_interfaces = all
#virtual_alias_maps = hash:/etc/postfix/virtual

如果我想閱讀日誌,/var/log/ 不包含 Postfix 日誌

謝謝你的幫助 !

我找到瞭如何糾正我的問題。

我的問題出在 Dovecot & Postfix 配置上。我的第一個問題是關於 SASL,postfix 無法連接到 SASL 文件夾。為了解決我的問題,我安裝了 rsyslog 並重新啟動 postfix 以顯示日誌,然後我按照每個問題來解決我的問題。

謝謝誰幫助了我!

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