第一次在运行最新Ubuntu的机器上设置自己的邮件服务器
环顾四周后,我决定在/ var / mail / vmail /%d /%n中添加邮箱的dovecot + postfix和虚拟用户
大部分情况下,我按照这里find的收回电子邮件教程系列
我注意到,当我尝试通过IMAP连接到[email protected]创build正确的目录结构,因此/var/mail/vmail/mydomain.com/dany存在,并具有所需的文件。
但是,当我通过SMTP在该服务器上收到邮件时,从Postfix到Dovecot的整个命令链中,域部分%d变为空,从而尝试访问并创build错误的目录,并失败这个错误:
Jan 25 17:47:35 lda(dany): Debug: Effective uid=1000, gid=1000, home=/home/dany Jan 25 17:47:35 lda(dany): Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/var/mail/vmail//dany/mail:LAYOUT=fs Jan 25 17:47:35 lda(dany): Debug: fs: root=/var/mail/vmail//dany/mail, index=, indexpvt=, control=, inbox=/var/mail/vmail//dany/mail, alt= Jan 25 17:47:35 lda(dany): Debug: Namespace : /var/mail/vmail//dany/mail doesn't exist yet, using default permissions Jan 25 17:47:35 lda(dany): Debug: Namespace : Using permissions from /var/mail/vmail//dany/mail: mode=0700 gid=default Jan 25 17:47:35 lda(dany): Error: User initialization failed: Namespace '': mkdir(/var/mail/vmail//dany/mail) failed: Permission denied (euid=1000(dany) egid=1000(dany) missing +w perm: /var/mail/vmail/, we're not in group 5000(vmail), dir owned by 5000:5000 mode=0775) Jan 25 17:47:35 lda(dany): Fatal: Invalid user settings. Refer to server log for more information.
/ var / mail / vmail由vmail:vmail(5000)拥有,即使不需要,我暂时将用户dany添加到vmail组。
我不知道如何进行debugging,我已经打开冗长的模式,我可以从后缀find鸽子,但从我得到的日志,我无法find问题的确切来源。
这是我的postfix master.cf的相关部分
dovecot unix - nn - - pipe flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
任何forms的帮助或build议非常感谢
更新1
事实certificate,有一个mailbox_command没有正确设置在后缀,所以我改变了
#mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot.conf -m "${EXTENSION}"
至
mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot.conf -f "${SENDER}" -d "${RECIPIENT}"
而现在我没有得到权限被拒绝的错误,但我仍然无法收到电子邮件
邮件位置设置是:
mail_home = /var/mail/vmail/%d/%n mail_location = maildir:/var/mail/vmail/%d/%n/mail:LAYOUT=fs
虚拟邮箱用户的内容是:
[email protected] mydomain.com/dany
而且我是每次修改后都映射该文件的
我注意到其他一些警告/错误:
Jan 25 20:43:29 linux2-dkhalife postfix/smtpd[8277]: warning: SASL: Connect to private/dovecot-auth failed: Connection refused Jan 25 20:43:29 linux2-dkhalife postfix/smtpd[8277]: fatal: no SASL authentication mechanisms Jan 25 20:42:26 linux2-dkhalife postfix/smtpd[8274]: warning: connect to Milter service unix:/var/spool/postfix/spamassassin/spamd.sock: No such file or directory Jan 25 20:42:26 linux2-dkhalife postfix/smtpd[8274]: warning: connect to Milter service unix:/var/run/clamav/clamav-milter.ctl: No such file or directory Jan 25 20:42:26 linux2-dkhalife postfix/smtpd[8274]: warning: connect to Milter service unix:/var/run/opendkim/opendkim.sock: No such file or directory
更新2
doveconf -n输出版本2.2.18和以下内容:
auth_mechanisms = plain login mail_debug = yes mail_home = /var/mail/vmail/%d/%n mail_location = maildir:/var/mail/vmail/%d/%n/mail:LAYOUT=fs mail_privileged_group = vmail managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate namespace inbox { inbox = yes location = mailbox Drafts { auto = subscribe special_use = \Drafts } mailbox Junk { auto = subscribe special_use = \Junk } mailbox Sent { auto = subscribe special_use = \Sent } mailbox "Sent Messages" { auto = subscribe special_use = \Sent } mailbox Trash { auto = subscribe special_use = \Trash } prefix = } passdb { args = username_format=%u scheme=ssha512 /etc/dovecot/passwd.db driver = passwd-file } plugin { sieve = ~/.dovecot.sieve sieve_after = /var/mail/vmail/sieve-after sieve_before = /var/mail/vmail/sieve-before sieve_dir = ~/sieve } protocols = imap pop3 sieve service auth { unix_listener /var/spool/postfix/private/auth { group = postfix mode = 0660 user = postfix } } ssl_cert = </etc/ssl/private/mail_mydomain_com.pem ssl_cipher_list = ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS ssl_client_ca_dir = /etc/ssl/certs ssl_key = </etc/ssl/private/mail_mydomain_com.key userdb { args = uid=5000 gid=5000 home=/var/mail/vmail/%d/%n driver = static } protocol imap { imap_client_workarounds = delay-newmail tb-extra-mailbox-sep mail_max_userip_connections = 10 } protocol pop3 { mail_max_userip_connections = 10 pop3_client_workarounds = outlook-no-nuls oe-ns-eoh } protocol lda { deliver_log_format = msgid=%m: %$ mail_plugins = sieve postmaster_address = [email protected] quota_full_tempfail = yes rejection_reason = Your message to <%t> was automatically rejected:%n%r }
postconf -n输出版本2.11.3和以下内容:
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 inet_protocols = all local_recipient_maps = mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot.conf -f "${SENDER}" -d "${RECIPIENT}" mailbox_size_limit = 0 message_size_limit = 104857600 milter_connect_macros = j {daemon_name} v {if_name} _ milter_default_action = accept mydestination = mydomain.com, myotherdomain.ca, localhost mydomain = mydomain.com myhostname = mail.mydomain.com mynetworks = 127.0.0.0/8 10.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 myorigin = /etc/mailname non_smtpd_milters = $smtpd_milters 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_mynetworks reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname, permit smtpd_milters = unix:/var/spool/postfix/spamassassin/spamd.sock unix:/var/run/clamav/clamav-milter.ctl unix:/var/run/opendkim/opendkim.sock smtpd_recipient_restrictions = reject_unknown_client_hostname, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, 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 = /var/spool/postfix/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/mail_mydomain_com.pem smtpd_tls_ciphers = high smtpd_tls_key_file = /etc/ssl/private/mail_mydomain_com.key smtpd_tls_loglevel = 0 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 unknown_address_reject_code = 550 unknown_client_reject_code = 550 unknown_hostname_reject_code = 550 virtual_alias_maps = hash:/etc/postfix/virtual virtual_mailbox_base = /var/mail/vmail virtual_mailbox_domains = hash:/etc/postfix/virtual-mailbox-domains virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox-users virtual_transport = dovecot
首先你的smtpd_sasl_path是错误的和错误的指定。 在dovecot.conf中设置为/var/spool/postfix/private/auth所以在Postfix中应该是smtpd_sasl_path = private/auth (不是.../dovecot-auth )。 注意这是相对于Postfix的chroot目录的相对path。 重新启动Postfix和SASL错误应该消失。
其次,它看起来像是混合虚拟邮件托pipe和“规范”的邮件托pipe。 你的虚拟域不能被设置在我的mydestination ,否则你会遇到像“邮件循环回自己”的问题。 决定你想要什么样的邮件托pipe设置,并相应地configurationPostfix和Dovecot。 不要试图混合configuration指令,希望某些组合会随机产生一个可行的结果。
这两个问题可能是你的问题的根源。 Dovecot的错误信息提示:
Jan 25 17:47:35 lda(dany): Error: User initialization failed: Namespace '': mkdir(/var/mail/vmail//dany/mail) failed: Permission denied (euid=1000(dany) egid=1000(dany) missing +w perm: /var/mail/vmail/, we're not in group 5000(vmail), dir owned by 5000:5000 mode=0775)
这是因为Postfix尝试使用mailbox_command (Dovecot的LDA deliver )作为接收消息的用户(dany)来传递邮件,但该用户当然没有业务写入/var/mail/vmail因为它是一个虚拟用户。
我将假设你想要正确的虚拟邮件托pipe,如讨论,例如,在http://www.postfix.org/VIRTUAL_README.html 。
您的Dovecot mail_location设置应该是mail_location = maildir:~/mail:LAYOUT=fs (问自己是否真的想要LAYOUT=fs而不是默认的Maildir ++布局)。 也不要在全局和userdb中设置mail_home 。 只要完全删除mail_home指令,它不需要您的设置。
因此,在使用虚拟传输( virtual_transport = dovecot )并且在master.cf中定义了一个dovecot服务后,您不需要Postfix中的mailbox_command。 见下一点。
这些天我会用LMTP而不是Dovecot的LDA deliver 。 更容易得到正确,更好的性能,它甚至给你的便宜的收件人validation。 请参阅http://wiki2.dovecot.org/HowTo/PostfixDovecotLMTP了解如何实现LMTP。
确保/var/mail/vmail的权限是正确的。 vmail目录和所有的子目录应该由UID 5000和GID 5000拥有,而没有其他人。 不要将任何其他用户放在该组中。
这是我可以说迄今为止,看着你的configuration和错误信息。 尝试解决上述问题,看看你到底在哪里。