jrgf 发表于 2018-12-14 14:19:58

三.mail 接收权限 dovecot加密通信 php数据库 thunderbird

  postconf -d:查看默认设置
postconf -n:查看当前设置
postconf -e "inet_interfaces = all":修改选项
inet_interfaces 参数指定postfix系统监听的网络接口。

  一.邮件的限制
==access==   ##禁止某个ip接受邮件
# cd /etc/postfix/
# ls
access   generic      main.cf    relocatedvirtual
canonicalheader_checksmaster.cftransport
# vim access
172.25.254.15    REJECT
# postmap access
# ls
access   canonicalheader_checksmaster.cftransport
access.dbgeneric    main.cf      relocatedvirtual
# postconf -d |grep smtpd_client_restrictions
smtpd_client_restrictions =
# postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
# postconf -d |grep smtpd_client_restrictions
smtpd_client_restrictions =
##太长了?
# tail -n 1 main.cf
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
# systemctl restart postfix.service

--测试--
$ telnet 172.25.254.115 25
Trying 172.25.254.115...
Connected to 172.25.254.115.
Escape character is '^]'.
220 maillinux.linux.com ESMTP Postfix
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 : Client host rejected: Access denied
quit
Connection closed by foreign host.

==sender==    ##禁止某个用户发送邮件
# vim access
删除
172.25.254.15    REJECT
# postmap access
# ls
access   canonicalheader_checksmaster.cftransport
access.dbgeneric    main.cf      relocatedvirtual
# vim sender
student@linux.com       REJECT
# postmap sender
# postconf -d |grep smtpd_sender_restrictions
smtpd_sender_restrictions =
# postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
# postconf -d |grep smtpd_sender_restrictionssmtpd_sender_restrictions =
##太长了?
# tail -n 1 main.cf
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender
# systemctl restart postfix.service

--测试--
$ telnet 172.25.254.115 25
Trying 172.25.254.115...
Connected to 172.25.254.115.
Escape character is '^]'.
220 maillinux.linux.com ESMTP Postfix
mail from:student@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 : Sender address rejected: Access denied
quit
221 2.0.0 Bye
Connection closed by foreign host.

==recipient==    ##禁止某个用户接受邮件
# vim recip
student@linux.com    REJECT
# postmap recip
# postconf -d |grep smtpd_recipient_restrictions
smtpd_recipient_restrictions =
# postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
# tail -n 1 main.cf
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip
# systemctl restart postfix.service

--测试--
$ telnet 172.25.254.115 25
Trying 172.25.254.115...
Connected to 172.25.254.115.
Escape character is '^]'.
220 maillinux.linux.com ESMTP Postfix
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:student@linux.com
554 5.7.1 : Recipient address rejected: Access denied
quit
221 2.0.0 Bye
Connection closed by foreign host.

  

  

  

  二.dovecot 加密通信
----------------------
dovecot
提供服务
imap 143pop3 110imaps 993pop3s 995

49不支持明文的话,不能用imap和pop3

按o

----------------------

==客户端==
# vim main.cf
删除
680 smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
681 smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender
682 smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/reci    p

  # systemctl restart postfix.service
  

# cat /etc/services |grep imap
imap            143/tcp         imap2         # Interim Mail Access Proto v2
imap            143/udp         imap2
imap3         220/tcp                         # Interactive Mail Access
imap3         220/udp                         # Protocol v3
imaps         993/tcp                         # IMAP over SSL
imaps         993/udp                         # IMAP over SSL
berknet         2005/tcp   csync      # csync for cyrus-imapd
oracle          2005/udp   csync      # csync for cyrus-imapd
# cat /etc/services |grep pop
# unfortunately the poppassd (Eudora) uses a port which has already
# been assigned to a different service. We list the poppassd as an
#3com-tsmux   106/tcp         poppassd
#3com-tsmux   106/udp         poppassd
pop2            109/tcp         pop-2 postoffice      # POP version 2
pop2            109/udp         pop-2
pop3            110/tcp         pop-3         # POP version 3
pop3            110/udp         pop-3
pop3s         995/tcp                         # POP-3 over SSL
pop3s         995/udp                         # POP-3 over SSL
kpop            1109/tcp                        # Pop with Kerberos
poppassd      106/tcp                         # Eudora
poppassd      106/udp                         # Eudora
hybrid-pop      473/tcp               # hybrid-pop
hybrid-pop      473/udp               # hybrid-pop
winpoplanmess   1152/tcp                # Winpopup LAN Messenger
winpoplanmess   1152/udp                # Winpopup LAN Messenger
popup-reminders 7787/tcp                # Popup Reminders Receive
popup-reminders 7787/udp                # Popup Reminders Receive

# yum install dovecot -y##dovecot(加密通信)
......
# cd /etc/dovecot
# vim dovecot.conf
-----------------------------------------------
24 protocols = imap pop3 lmtp

46 # for authentication checks). disable_plaintext_auth is also ignored for

48 login_trusted_networks = 0.0.0.0/0
49 disable_plaintext_auth = no
-----------------------------------------------
# cd conf.d
# ls
10-auth.conf       20-imap.conf               auth-dict.conf.ext
10-director.conf   20-lmtp.conf               auth-ldap.conf.ext
10-logging.conf    20-pop3.conf               auth-master.conf.ext
10-mail.conf       90-acl.conf                  auth-passwdfile.conf.ext
10-master.conf   90-plugin.conf               auth-sql.conf.ext
10-ssl.conf      90-quota.conf                auth-static.conf.ext
15-lda.conf      auth-checkpassword.conf.extauth-system.conf.ext
15-mailboxes.confauth-deny.conf.ext         auth-vpopmail.conf.ext
# vim 10-mail.conf
-----------------------------------------------
17 #   %u - username

25 #   mail_location = mbox:~/mail:INBOX=/var/mail/%u

30 mail_location = mbox:~/mail:INBOX=/var/mail/%u
-----------------------------------------------
# ll /var/mail
lrwxrwxrwx. 1 root root 10 May62014 /var/mail -> spool/mail
# ll /var/spool/mail/
total 4
-rw-------. 1 root    mail 1263 Dec2 20:50 root
-rw-rw----. 1 rpc   mail    0 May62014 rpc
-rw-rw----. 1 student mail    0 Jul 102014 student
# ls /var/mail
rootrpcstudent
# systemctl start dovecot
# netstat -antlpe | grep dovecot
tcp      0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      0          87375      32078/dovecot      
tcp      0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      0          87351      32078/dovecot      
tcp      0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      0          87349      32078/dovecot      
tcp      0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      0          87373      32078/dovecot      
tcp6       0      0 :::993                  :::*                  LISTEN      0          87376      32078/dovecot      
tcp6       0      0 :::995                  :::*                  LISTEN      0          87352      32078/dovecot      
tcp6       0      0 :::110                  :::*                  LISTEN      0          87350      32078/dovecot      
tcp6       0      0 :::143                  :::*                  LISTEN      0          87374      32078/dovecot   
# useradd westos
# passwd westos
Changing password for user westos.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

mutt -s "subject" -a /backup/backup.tar.gz xxx@126.com < /tmp/x.txt
-s:邮件标题,用""括上。
-a:邮件附件。如上命令就是将/backup目录下 backup.tar.gz文件作为附件发送。
< /tmp/x.txt: /tmp目录下x.txt文件里的内容作为邮件内容发送。

# yum install mutt -y   ##mutt邮件发送
# mutt -f pop://westos@172.25.254.215
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
(r)eject, accept (o)nce, (a)ccept always
##按"o"
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
Password for westos@172.25.254.215:
##弹出

# cat /var/log/message
发现:Error: chown(/home/westos/mail/.imap, group=12(mail)) failed
# su - westos
$ ls
mail
$ cd mail
$ ls
$ mkdir .imap
$ exit
logout
# > /var/log/maillog
# tail -f /var/log/maillog

  

  

  三.mutt邮箱
# mutt -f   pop://westos@172.25.254.215
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
(r)eject, accept (o)nce, (a)ccept always
##按"o"
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
Password for westos@172.25.254.215:
##弹出

# tail -f /var/log/maillog
发现
Error: chown(/home/westos/mail/.imap/INBOX, group=12(mail)) failed
# ps aux |grep dovecot
root   320780.00.1198401556 ?      Ss   Dec02   0:00 /usr/sbin/dovecot -F
dovecot320810.00.0   9312   980 ?      S    Dec02   0:00 dovecot/anvil
root   320820.00.1   94401152 ?      S    Dec02   0:00 dovecot/log
root   323200.00.0 112640   940 pts/0    S+   00:04   0:00 grep --color=auto dovecot
# su - westos
Last login: Sat Dec3 00:01:23 EST 2016 on pts/0
$ touch /home/westos/mail/.imap/INBOX

# mutt -f pop://westos@172.25.254.215
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
(r)eject, accept (o)nce, (a)ccept always
##按"o"
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
Password for westos@172.25.254.215:
##进入
q
##退出

  

  四.root 自动建立

  root用户建立此/etc/skel/mail/.imap/INBOX目录后

  ##root创建普通用户 自动生成/etc/skel/mail/.imap目录
  建立的普通用户会自动生成 mail/.imap/INBOX
  
# su - student
$ ls -a
....bash_logout.bash_profile.bashrc.cache.config.ssh
$ logout
# cd /etc/skel/
# ls -a
....bash_logout.bash_profile.bashrc.config.mozilla
# mkdir mail/.imap/ -p
# touch mail/.imap/INBOX
# cd
# useradd lee
# su - lee
$ ls
mail
$ cd mail/
$ ls -a
....imap
$ cd .imap/
$ ls
INBOX
$ ll
total 0
-rw-r--r--. 1 lee lee 0 Dec3 00:15 INBOX
$ logout
# passwd lee
Changing password for user lee.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

# mutt -f pop://lee@172.25.254.215
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
(r)eject, accept (o)nce, (a)ccept always
##按"o"
-- Mutt: SSL Certificate check (certificate 1 of 1 in chain)
Password for lee@172.25.254.215:
##进入
q
##退出

  

  五.安装thunderbird
# yum install lftp -y
......
# cd /mnt
# lftp 172.25.254.250
lftp 172.25.254.250:~> cd /pub/docs/software
cd ok, cwd=/pub/docs/software
lftp 172.25.254.250:/pub/docs/software> ls
-rwxr-xr-x    1 1000   1000      3086326 Dec 252013 phpMyAdmin-2.11.3-all-languages.tar.bz2
-rwxr-xr-x    1 1000   1000      4548030 Dec 252013 phpMyAdmin-3.4.0-all-languages.tar.bz2
-rw-rw-r--    1 1000   1000      2713600 Jun 072015 taobao.tar
-rwxr-xr-x    1 1000   1000   52387876 Feb 012015 thunderbird-31.2.0-1.el7.x86_64.rpm
-rwxr-xr-x    1 1000   1000   36902724 Feb 012015 thunderbird-31.4.0.tar.bz2
lftp 172.25.254.250:/pub/docs/software> get thunderbird-31.4.0.tar.bz2
36902724 bytes transferred                                    
lftp 172.25.254.250:/pub/docs/software> quit
# ls
thunderbird-31.4.0.tar.bz2
# tar jxf thunderbird-31.4.0.tar.bz2
# ls
thunderbirdthunderbird-31.4.0.tar.bz2
# cd thunderbird/
# ls
application.ini   libldif60.so      libxul.so
blocklist.xml       libmozalloc.so    mozilla-xremote-client
chrome            libmozsqlite3.soomni.ja
chrome.manifest   libnspr4.so       platform.ini
components          libnss3.so      plugin-container
crashreporter       libnssckbi.so   precomplete
crashreporter.ini   libnssdbm3.chk    removed-files
defaults            libnssdbm3.so   run-mozilla.sh
dependentlibs.listlibnssutil3.so    searchplugins
dictionaries      libplc4.so      Throbber-small.gif
extensions          libplds4.so       thunderbird
icons               libprldap60.so    thunderbird-bin
isp               libsmime3.so      updater
libfreebl3.chk      libsoftokn3.chk   updater.ini
libfreebl3.so       libsoftokn3.so    update-settings.ini
libldap60.so      libssl3.so
  
# ./thunderbird
-bash: ./thunderbird: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
# yum whatprovides /lib/ld-linux.so.2
Loaded plugins: langpacks
rhel_dvd/filelists_db                                    | 3.0 MB   00:00   
glibc-2.17-55.el7.i686 : The GNU libc libraries
Repo      : rhel_dvd
Matched from:
Filename    : /lib/ld-linux.so.2

# yum install glibc-2.17-55.el7.i686 -y
......
---类似方法,直到装好---
144./thunderbird
145yum whatprovides /lib/ld-linux.so.2
146yum install glibc-2.17-55.el7.i686 -y
147./thunderbird
148yum whatprovides */libstdc++.so.6
149yum install libstdc++-4.8.2-16.el7.i686 -y
150./thunderbird
151yum whatprovides */libXrender.so.1
152yum install libXrender-0.9.8-2.1.el7.i686 -y
153./thunderbird
154yum whatprovides */libasound.so.2
155yum install alsa-lib-1.0.27.2-3.el7.i686 -y
156./thunderbird
157yum whatprovides */libdbus-glib-1.so.2
158yum install dbus-glib-0.100-7.el7.i686 -y
159./thunderbird
160yum whatprovides */libgtk-x11-2.0.so.0
161yum install gtk2-2.24.22-5.el7.i686 -y
162./thunderbird
163yum whatprovides */libXt.so.6
164yum install libXt-1.1.4-6.1.el7.i686 -y
165./thunderbird

# ./thunderbird &

登陆
设定帐号westos(略),同下面lee设定

# mail westos@westos.com
Subject: 111
111
111
.
EOT
# mailq
Mail queue is empty

查看图形,收到邮件111

左边空白处右键点击设定,帐号操作,新增电子邮箱帐号
您的大名:lee
电子邮件地址:lee@westos.com
密码:lee
记住密码
-->继续

IMAP    172.25.254.215    143    无    自动检测
SMTP    172.25.254.215    25    无    自动检测

-->重新测试
-->完成
我了解危险性>打钩
-->完成

-->确定

写信
至:westos@westos.com
主旨:22
内文:
222
222
-->传送

查看westos@westos.com收件夹
收到邮件:222

# mail -u westos
Heirloom Mail version 12.5 7/5/10.Type ? for help.
"/var/mail/westos": 2 messages 1 unread
    1 root                  Sat Dec3 00:4022/669   "111"
>U2 lee                   Sat Dec3 00:4622/750   "222"
& 2
Message2:
From lee@westos.comSat Dec3 00:46:50 2016
Return-Path:
X-Original-To: westos@westos.com
Delivered-To: westos@westos.com
Date: Sat, 03 Dec 2016 00:46:50 -0500
From: lee
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
To: westos@westos.com
Subject: 222
Content-Type: text/plain; charset=utf-8; format=flowed
X-UID: 2                                                
Status: RO

222
222

& q
Held 2 messages in /var/mail/westos

# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is '^]'.
+OK Dovecot ready.
user student
+OK
pass student
-ERR Permission denied
Connection closed by foreign host.
##权限不够
# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is '^]'.
+OK Dovecot ready.
user lee
+OK
pass lee
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.


六.==smtp连接mysql==
107yum install httpd php php-mysql -y
108yum instal lftp
109yum install lftp -y
110yum install mariadb-server.x86_64 -y
# cd /var/www/html/
# lftp 172.25.254.250
lftp 172.25.254.250:~> cd /pub/docs/software
cd ok, cwd=/pub/docs/software
lftp 172.25.254.250:/pub/docs/software> ls
-rwxr-xr-x    1 1000   1000      3086326 Dec 252013 phpMyAdmin-2.11.3-all-languages.tar.bz2
-rwxr-xr-x    1 1000   1000      4548030 Dec 252013 phpMyAdmin-3.4.0-all-languages.tar.bz2
-rw-rw-r--    1 1000   1000      2713600 Jun 072015 taobao.tar
-rwxr-xr-x    1 1000   1000   52387876 Feb 012015 thunderbird-31.2.0-1.el7.x86_64.rpm
-rwxr-xr-x    1 1000   1000   36902724 Feb 012015 thunderbird-31.4.0.tar.bz2
lftp 172.25.254.250:/pub/docs/software> get phpMyAdmin-3.4.0-all-languages.tar.bz2
4548030 bytes transferred                                       
lftp 172.25.254.250:/pub/docs/software> quit
# ls
phpMyAdmin-3.4.0-all-languages.tar.bz2
# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2
# ls
phpMyAdmin-3.4.0-all-languagesphpMyAdmin-3.4.0-all-languages.tar.bz2
# rm -fr phpMyAdmin-3.4.0-all-languages.tar.bz2
# mv phpMyAdmin-3.4.0-all-languages/ myadmin
# cd myadmin/
# cp -p config.sample.inc.php config.inc.php
# vim config.inc.php
17 $cfg['blowfish_secret'] = 'westos'; /* YOU MUST FILL IN THIS FOR COOKIE AU    TH! */
# systemctl start httpd
# systemctl start mariadb
# mysql_secure_installation
密码:westos
# systemctl restart mariadb
# cd
# firefox &
配置email库muser表4个字段
插入一行用户信息

表用户的域一定要和本机的域 区分开

root@mailwestos ~]# mysql -uroot -pwestos
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select * from email.muser;
+------------------+----------+------------+-------------------------------+
| username         | password | domain   | maildir                     |
+------------------+----------+------------+-------------------------------+
| admin@westos.org | 123      | westos.org | /home/vmail/westos.org/admin/ |
+------------------+----------+------------+-------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> CREATE USER postfix@localhost identified by 'postfix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT INSERT,UPDATE,SELECT on email.* to postfix@localhost;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye
# mysql -upostfix -ppostfix
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT * FROM email.muser;
+------------------+----------+------------+-------------------------------+
| username         | password | domain   | maildir                     |
+------------------+----------+------------+-------------------------------+
| admin@westos.org | 123      | westos.org | /home/vmail/westos.org/admin/ |
+------------------+----------+------------+-------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> quit

# cd /etc/postfix/
# vim mysql-users.cf
1 hosts = localhost
2 user = postfix
3 password = postfix
4 dbname = email
5 table = muser
6 select_field = username
7 where_field = username
# postmap -q "admin@westos.org" mysql:/etc/postfix/mysql-users.cf
admin@westos.org
# vim mysql-domain.cf
6 select_field = domain
7 where_field = domain
# postmap -q "westos.org" mysql:/etc/postfix/mysql-domain.cf
westos.org
# vim mysql-maildir.cf
6 select_field = maildir
7 where_field = username
# postmap -q "admin@westos.org" mysql:/etc/postfix/mysql-maildir.cf
/home/vmail/westos.org/admin/

网页上添加一个lee用户

# postmap -q "admin@westos.org" mysql:/etc/postfix/mysql-users.cf
admin@westos.org
# postmap -q "westos.org" mysql:/etc/postfix/mysql-domain.cf
westos.org,westos.org
# postmap -q "admin@westos.org" mysql:/etc/postfix/mysql-maildir.cf
/home/vmail/westos.org/admin/

# groupadd vmail -g 666
# useradd -u 666 -g 666 -s /sbin/nologin vmail
# postconf -d | grep virtual
......    ##不要自己敲,尽量复制粘贴
# postconf -e "virtual_gid_maps = static:666"
# postconf -e "virtual_uid_maps = static:666"
# postconf -e "virtual_mailbox_base = /home/vmail"
# postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf"
# ll /etc/postfix/mysql-users.cf
-rw-r--r--. 1 root root 128 Dec3 02:34 /etc/postfix/mysql-users.cf
# postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
# ll /etc/postfix/mysql-domain.cf
-rw-r--r--. 1 root root 124 Dec3 02:37 /etc/postfix/mysql-domain.cf
# postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf"
# ll /etc/postfix/mysql-maildir.cf
-rw-r--r--. 1 root root 127 Dec3 02:38 /etc/postfix/mysql-maildir.cf

vim /etc/postfix/main.cf
virtual_gid_maps = static:666
virtual_uid_maps = static:666
virtual_mailbox_base = /home/vmail
virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf

修改数据库maildir字段
# mysql -upostfix -ppostfix
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 48
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT * FROM email.muser;
+------------------+----------+------------+-------------------+
| username         | password | domain   | maildir         |
+------------------+----------+------------+-------------------+
| admin@westos.org | 123      | westos.org | westos.org/admin/ |
| lee@westos.org   | 123      | westos.org | westos.org/lee/   |
+------------------+----------+------------+-------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

# mail admin@westos.org
Subject: test
test
.
EOT
# mailq
Mail queue is empty

# cd /home
# ls
leestudentvmailwestos
# cd vmail
# ls
mailwestos.org            ##哪来的mail,应该只有westos.org
# cd westos.org/
# ls
admin
# cd admin
# ls
curnewtmp

# cd /etc/dovecot/
# ls
conf.ddovecot.conf
# cd conf.d/
# ls
10-auth.conf       20-imap.conf               auth-dict.conf.ext
10-director.conf   20-lmtp.conf               auth-ldap.conf.ext
10-logging.conf    20-pop3.conf               auth-master.conf.ext
10-mail.conf       90-acl.conf                  auth-passwdfile.conf.ext
10-master.conf   90-plugin.conf               auth-sql.conf.ext
10-ssl.conf      90-quota.conf                auth-static.conf.ext
15-lda.conf      auth-checkpassword.conf.extauth-system.conf.ext
15-mailboxes.confauth-deny.conf.ext         auth-vpopmail.conf.ext
# vim 10-auth.conf
122 !include auth-system.conf.ext
123 !include auth-sql.conf.ext
# vim auth-sql.conf.ext
8   # Path for SQL configuration file, see example-config/dovecot-sql.conf.e    xt
# cd /usr/share/doc/dovecot-2.2.10/
# ls
AUTHORS    COPYING.LGPL       dovecot-openssl.cnfNEWS             wiki
ChangeLogCOPYING.MIT      example-config       README
COPYING    documentation.txtmkcert.sh            solr-schema.xml
# cd example-config/
# ls
conf.d      dovecot-dict-auth.conf.extdovecot-ldap.conf.ext
dovecot.confdovecot-dict-sql.conf.ext   dovecot-sql.conf.ext
# cp dovecot-sql.conf.ext /etc/dovecot/
# cd /etc/dovecot/
# ls
conf.ddovecot.confdovecot-sql.conf.ext
# vim dovecot-sql.conf.ext
32 driver = mysql
71 connect = host=localhost dbname=email user=postfix password=postfix
78 default_pass_scheme = PLAIN
107 password_query = \
108   SELECT username, domain, password \
109   FROM muser WHERE username = '%u' AND domain = '%d'
125 user_query = SELECT maildir, 666 AS uid, 666 AS gid FROM muser WHERE username = '%u'
# cd conf.d/
# vim 10-mail.conf
30 mail_location = maildir:/home/vmail/%d/%n
168 first_valid_uid = 666
175 first_valid_gid = 666
# systemctl restart dovecot.service
# yum install telnet -y
# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is '^]'.
-ERR Disconnected: Auth process broken
Connection closed by foreign host.
# tail -n 5 /var/log/maillog
发现
Dec3 03:53:30 maillinux dovecot: auth: Fatal: Unknown database driver 'mysql'
# yum search dovecot
Loaded plugins: langpacks
============================ N/S matched: dovecot ============================
dovecot-mysql.x86_64 : MySQL back end for dovecot
dovecot-pgsql.x86_64 : Postgres SQL back end for dovecot
dovecot-pigeonhole.x86_64 : Sieve and managesieve plug-in for dovecot
dovecot.i686 : Secure imap and pop3 server
dovecot.x86_64 : Secure imap and pop3 server

Name and summary matches only, use "search all" for everything.
# yum install dovecot-mysql -y
......
# systemctl restart dovecot.service

# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is '^]'.
+OK Dovecot ready.
user admin@westos.org
+OK
pass 123
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is '^]'.
+OK Dovecot ready.
user lee@westos.org
+OK
pass 123
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.


使用雷鸟进行测试


注册一个新的邮箱,发一封邮件,是给你建立邮件目录

[*]  




页: [1]
查看完整版本: 三.mail 接收权限 dovecot加密通信 php数据库 thunderbird