[email protected]
在这种情况下,我使用虚构的电子邮件地址。testuser
是我的 ubuntu Server 14.04 上的本地帐户。
我有一个功能齐全的电子邮件服务器,使用 postfix 和 dovecot 设置如下ArsTechnica 上的指南
我对某些本地发送的消息有疑问。大多数消息都能正常发送(例如,由用户 crontab 生成),但以下消息不能。它们会停留在队列中,并且永远不会发送,原因是以下错误:
Nov 14 10:32:36 mail dovecot: lda(testuser): Error: user testuser: Initialization failed: Namespace '': mkdir(/var/mail/vmail//testuser/mail) failed: Permission denied (euid=1000(testuser) egid=1000(testuser) missing +w perm: /var/mail/vmail/, dir owned by 5000:5000 mode=0755)
这包括使用以下方式发送的测试消息sendmail -bv [email protected]
队列如下所示:
79B4A812E1 2023 Fri Nov 14 10:17:46 MAILER-DAEMON
(temporary failure)
[email protected]
我有一个文件夹结构 /var/mail/vmail/domainname.com/username/mail/
因此,dovecot 不使用 domainname.com 文件夹,也不使用 username 文件夹。我在网上找到了一个可能的解决方案,使用mail_location
中的设置/etc/dovecot/conf.d/10-mail.conf
,但我担心这不是一个完美的解决方案,因为其他本地进程确实会将邮件发送到正确的地址。这也是来自用户 ID 1000(testuser)
当使用 读取队列中的一条消息时postqueue -q <MESSAGE_ID>
,它确实会将邮件发送到有效的 To: 地址。但是,它尝试从用户 ID 1000 发送,也许它应该尝试将其中继到用户 vmail(uid gid 5000)?
这是输出postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
canonical_maps = hash:/etc/postfix/canonical
config_directory = /etc/postfix
default_destination_concurrency_limit = 5
disable_vrfy_command = yes
dovecot_destination_recipient_limit = 1
home_mailbox = Maildir/
inet_interfaces = all
mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot.conf -m "${EXTENSION}"
mailbox_size_limit = 0
message_size_limit = 104857600
milter_connect_macros = j {daemon_name} v {if_name} _
milter_default_action = accept
milter_protocol = 2
mydestination = localhost, localhost.localdomain, domainname.com
myhostname = domainname.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
non_smtpd_milters = $smtpd_milters
postscreen_access_list = permit_mynetworks
postscreen_dnsbl_action = enforce
postscreen_dnsbl_sites = zen.spamhaus.org, b.barracudacentral.org, bl.spamcop.net
postscreen_greet_action = enforce
readme_directory = no
recipient_delimiter = +
relay_destination_concurrency_limit = 1
relayhost =
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname, permit
smtpd_milters = unix:/spamass/spamass.sock unix:/clamav/clamav-milter.ctl unix:/opendkim/opendkim.sock
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unknown_client_hostname, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination, reject_invalid_hostname, reject_non_fqdn_sender
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/dovecot-auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_login_maps = $virtual_mailbox_maps
smtpd_sender_restrictions = reject_unknown_sender_domain, reject_sender_login_mismatch
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtpd_tls_ask_ccert = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/private/ssl-chain-mail-domainname.com.pem
smtpd_tls_ciphers = high
smtpd_tls_key_file = /etc/ssl/private/ssl-key-decrypted-mail-domainname.com.key
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_ciphers = medium
smtpd_tls_mandatory_protocols = SSLv3, TLSv1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_domains = hash:/etc/postfix/virtual-mailbox-domains
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox-users
virtual_transport = dovecot
答案1
我已经解决了。
这实际上是一个不起作用的 crontab 条目邮件程序,与我在问题中声称的相反。本地用户testuser
没有定义/etc/aliases
真实的电子邮件地址,因此它会尝试仅从帐户名称“testuser”发送邮件,这是无效的。
正确的输入/etc/aliases
如下:
testuser: [email protected]