Ubuntu 16.04新的邮件服务器可以收到,但不能发送电子邮件

我跟着在Digitalocean上发现的一步一步的教程如何在Postfix,Dovecot,Mysql上设置Ubuntu的邮件服务器(我把最后一个改为MariaDB)。

我面临的问题是我可以收到邮件,但我不能发送任何邮件。

也许很高兴知道我用我的用户和关键字sudo做了整个安装。

所以我现在已经有这个问题了两个星期了,并且尝试了很多东西,现在是时候在这里试试我的运气了。

当运行sudo service postfix status我看到下面的错误返回

 May 06 09:27:05 mailserver01 postfix/qmgr[8494]: 6AC1F2C093A: from=<[email protected]>, size=652, nrcpt=1 (queue active) May 06 09:27:05 mailserver01 postfix/postdrop[25691]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied May 06 09:27:06 mailserver01 postfix/sendmail[25689]: warning: command "/usr/sbin/postdrop -r" exited with status 1 May 06 09:27:06 mailserver01 postfix/sendmail[25689]: fatal: [email protected](1001): unable to execute /usr/sbin/postdrop -r: Success May 06 09:27:06 mailserver01 postfix/pipe[25688]: 6AC1F2C093A: to=<[email protected]>, relay=spamassassin, delay=147723, delays=147722/0/0/1, dsn=4.3.0, status=deferred (temporary failure. Command output: postdrop: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied sendmail: status=deferred (temporary failure. Command output: postdrop: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied sendmail: warning: command "/usr/sbin/postdrop -r" exited with status 1 sendmail: fatal: [email protected](1001): unable to execute /usr/sbin/postdrop -r: Success ) May 06 09:33:48 mailserver01 postfix/submission/smtpd[25746]: connect from cust-228-37-109-94.dyn.as47377.net[94.109.37.228] 

也许这可能是一个权限问题,我意识到这一点,但只是要清楚,我已经尝试使用root,postfix,myuser,dovecot和spamd作为该组的用户创build一个新组。 然后,我给这个组读取和写入该postfix文件夹和子文件夹的权限。 没有运气…

这里是今天的权限:

 -rw-r----- 1 root root 153 Apr 28 12:51 dynamicmaps.cf -rw-r--r-- 1 root root 2674 May 5 09:05 main.cf -rw-r----- 1 root root 1388 Apr 28 14:23 main.cf.orig -rw-r----- 1 root root 6261 May 5 09:49 master.cf -rw-r----- 1 root postfix 142 May 1 13:07 mysql-virtual-alias-maps.cf -rw-r----- 1 root postfix 130 May 1 13:08 mysql-virtual-mailbox-domains.cf -rw-r----- 1 root postfix 129 May 1 13:07 mysql-virtual-mailbox-maps.cf -rw-r----- 1 root root 21233 Apr 13 2016 postfix-files -rwxr-x--- 1 root root 9344 Apr 13 2016 postfix-script -rwxr-x--- 1 root root 29446 Apr 13 2016 post-install drwxr-x--- 2 root root 4096 Apr 13 2016 sasl 

有人有一个想法如何解决这个问题?

postdrop通常会应用setgid位,这意味着当spamassasin等其他进程使用它传递邮件时,该进程将在其他进程用户(例如spamassasin)下执行,但是会postdrop组:

 $ ls -la `which postdrop` -r-xr-sr-x 1 root postdrop 14328 Feb 5 2015 /usr/sbin/postdrop ^ ^ | | setgid bit set executed with postdrop's privileges 

现在日志告诉你, postdrop不能访问它必须读取的configuration文件:

 May 06 09:27:05 mailserver01 postfix/postdrop[25691]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied 

查看该文件的权限,该文件可以被root用户读取和写入,并且可以被根组读取。 这是别人不可读的(这是一件好事)。

 -rw-r----- 1 root root 153 Apr 28 12:51 dynamicmaps.cf 

要解决此问题,请将文件所有权更改为postdrop组( chown postdrop /etc/postfix/dynamicmaps.cf )。 读取权限应该足够了,所以没有理由修改权限。 如果其他文件也需要调整权限,请逐一进行(或者只是仔细重新考虑所需的权限)。 通常情况下,服务器进程拒绝执行任何操作,如果他们认识到广泛发布的权限,以通知您去除系统中每个人的读写权限造成的安全问题。