今天我按照本教程创建了一个邮件服务器: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 日志
感谢您的帮助 !
答案1
我找到了解决我的问题的方法。
我的问题出在 Dovecot 和 Postfix 配置上。我的第一个问题出在 SASL 上,postfix 无法连接到 SASL 文件夹。为了解决我的问题,我安装了 rsyslog 并重新启动 postfix 以显示日志,然后我按照每个问题来解决我的问题。
感谢那些帮助过我的人!