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

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

一.邮件的限制
==access==   ##禁止某个ip接受邮件
[[email protected] ~]# cd /etc/postfix/
[[email protected] postfix]# ls
access     generic        main.cf    relocated  virtual
canonical  header_checks  master.cf  transport
[[email protected] postfix]# vim access
172.25.254.15    REJECT
[[email protected] postfix]# postmap access
[[email protected] postfix]# ls
access     canonical  header_checks  master.cf  transport
access.db  generic    main.cf        relocated  virtual
[[email protected] postfix]# postconf -d |grep smtpd_client_restrictions
smtpd_client_restrictions =
[[email protected] postfix]# postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
[[email protected] postfix]# postconf -d |grep smtpd_client_restrictions
smtpd_client_restrictions =
##太长了?
[[email protected] postfix]# tail -n 1 main.cf
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
[[email protected] postfix]# systemctl restart postfix.service

--测试--
[[email protected] Desktop]$ 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <unknown[172.25.254.15]>: Client host rejected: Access denied
quit
Connection closed by foreign host.

==sender==    ##禁止某个用户发送邮件
[[email protected] postfix]# vim access
删除
172.25.254.15    REJECT
[[email protected] postfix]# postmap access
[[email protected] postfix]# ls
access     canonical  header_checks  master.cf  transport
access.db  generic    main.cf        relocated  virtual
[[email protected] postfix]# vim sender
[email protected]       REJECT
[[email protected] postfix]# postmap sender
[[email protected] postfix]# postconf -d |grep smtpd_sender_restrictions
smtpd_sender_restrictions =
[[email protected] postfix]# postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
[[email protected] postfix]# postconf -d |grep smtpd_sender_restrictionssmtpd_sender_restrictions =
##太长了?
[[email protected] postfix]# tail -n 1 main.cf
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender
[[email protected] postfix]# systemctl restart postfix.service

--测试--
[[email protected] Desktop]$ 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <[email protected]>: Sender address rejected: Access denied
quit
221 2.0.0 Bye
Connection closed by foreign host.

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

--测试--
[[email protected] Desktop]$ 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <[email protected]>: Recipient address rejected: Access denied
quit
221 2.0.0 Bye
Connection closed by foreign host.

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

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

按o

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

==客户端==
[[email protected] postfix]# 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

[[email protected] postfix]# systemctl restart postfix.service

[[email protected] ~]# 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
[[email protected] ~]# 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

[[email protected] ~]# yum install dovecot -y  ##dovecot(加密通信)
......
[[email protected] ~]# cd /etc/dovecot
[[email protected] 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
-----------------------------------------------
[[email protected] dovecot]# cd conf.d
[[email protected] 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.ext  auth-system.conf.ext
15-mailboxes.conf  auth-deny.conf.ext           auth-vpopmail.conf.ext
[[email protected] conf.d]# 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
-----------------------------------------------
[[email protected] conf.d]# ll /var/mail
lrwxrwxrwx. 1 root root 10 May  6  2014 /var/mail -> spool/mail
[[email protected] conf.d]# ll /var/spool/mail/
total 4
-rw-------. 1 root    mail 1263 Dec  2 20:50 root
-rw-rw----. 1 rpc     mail    0 May  6  2014 rpc
-rw-rw----. 1 student mail    0 Jul 10  2014 student
[[email protected] mail]# ls /var/mail
root  rpc  student
[[email protected] mail]# systemctl start dovecot
[[email protected] mail]# 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    
[[email protected] mail]# useradd westos
[[email protected] mail]# 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 [email protected] < /tmp/x.txt
-s:邮件标题,用""括上。
-a:邮件附件。如上命令就是将/backup目录下 backup.tar.gz文件作为附件发送。
< /tmp/x.txt: /tmp目录下x.txt文件里的内容作为邮件内容发送。

[[email protected] ~]# yum install mutt -y   ##mutt邮件发送
[[email protected] ~]# mutt -f pop://[email protected]
-- 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 [email protected]:
##弹出

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

三.mutt邮箱
[[email protected] ~]# mutt -f   pop://[email protected]
-- 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 [email protected]:
##弹出

[[email protected] mail]# tail -f /var/log/maillog
发现
Error: chown(/home/westos/mail/.imap/INBOX, group=12(mail)) failed
[[email protected] mail]# ps aux |grep dovecot
root     32078  0.0  0.1  19840  1556 ?        Ss   Dec02   0:00 /usr/sbin/dovecot -F
dovecot  32081  0.0  0.0   9312   980 ?        S    Dec02   0:00 dovecot/anvil
root     32082  0.0  0.1   9440  1152 ?        S    Dec02   0:00 dovecot/log
root     32320  0.0  0.0 112640   940 pts/0    S+   00:04   0:00 grep --color=auto dovecot
[[email protected] mail]# su - westos
Last login: Sat Dec  3 00:01:23 EST 2016 on pts/0
[[email protected] ~]$ touch /home/westos/mail/.imap/INBOX

[[email protected] ~]# mutt -f pop://[email protected]
-- 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 [email protected]:
##进入
q
##退出

[[email protected] mail]# su - student
[[email protected] ~]$ ls -a
.  ..  .bash_logout  .bash_profile  .bashrc  .cache  .config  .ssh
[[email protected] ~]$ logout
[[email protected] mail]# cd /etc/skel/
[[email protected] skel]# ls -a
.  ..  .bash_logout  .bash_profile  .bashrc  .config  .mozilla
[[email protected] skel]# mkdir mail/.imap/ -p
[[email protected] skel]# touch mail/.imap/INBOX
[[email protected] skel]# cd
[[email protected] ~]# useradd lee
[[email protected] ~]# su - lee
[[email protected] ~]$ ls
mail
[[email protected] ~]$ cd mail/
[[email protected] mail]$ ls -a
.  ..  .imap
[[email protected] mail]$ cd .imap/
[[email protected] .imap]$ ls
INBOX
[[email protected] .imap]$ ll
total 0
-rw-r--r--. 1 lee lee 0 Dec  3 00:15 INBOX
[[email protected] .imap]$ logout
[[email protected] ~]# 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.

[[email protected]undation15 ~]# mutt -f pop://[email protected]
-- 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 [email protected]:
##进入
q
##退出

[[email protected] postfix]# yum install lftp -y
......
[[email protected] postfix]# cd /mnt
[[email protected] postfix]# 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 25  2013 phpMyAdmin-2.11.3-all-languages.tar.bz2
-rwxr-xr-x    1 1000     1000      4548030 Dec 25  2013 phpMyAdmin-3.4.0-all-languages.tar.bz2
-rw-rw-r--    1 1000     1000      2713600 Jun 07  2015 taobao.tar
-rwxr-xr-x    1 1000     1000     52387876 Feb 01  2015 thunderbird-31.2.0-1.el7.x86_64.rpm
-rwxr-xr-x    1 1000     1000     36902724 Feb 01  2015 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
[[email protected] mnt]# ls
thunderbird-31.4.0.tar.bz2
[[email protected] mnt]# tar jxf thunderbird-31.4.0.tar.bz2
[[email protected] mnt]# ls
thunderbird  thunderbird-31.4.0.tar.bz2
[[email protected] mnt]# cd thunderbird/
[[email protected] thunderbird]# ls
application.ini     libldif60.so      libxul.so
blocklist.xml       libmozalloc.so    mozilla-xremote-client
chrome              libmozsqlite3.so  omni.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.list  libnssutil3.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

[[email protected] thunderbird]# ./thunderbird
-bash: ./thunderbird: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
[[email protected] thunderbird]# 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

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

[[email protected] thunderbird]# ./thunderbird &

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

[[email protected] ~]# mail [email protected]
Subject: 111
111
111
.
EOT
[[email protected] ~]# mailq
Mail queue is empty

查看图形,收到邮件111

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

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

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

-->确定

写信
至:[email protected]
主旨:22
内文:
222
222
-->传送

查看[email protected]收件夹
收到邮件:222

[[email protected] ~]# mail -u westos
Heirloom Mail version 12.5 7/5/10.  Type ? for help.
"/var/mail/westos": 2 messages 1 unread
    1 root                  Sat Dec  3 00:40  22/669   "111"
>U  2 lee                   Sat Dec  3 00:46  22/750   "222"
& 2
Message  2:
From [email protected]  Sat Dec  3 00:46:50 2016
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Date: Sat, 03 Dec 2016 00:46:50 -0500
From: lee <[email protected]>
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
To: [email protected]
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

[[email protected] ~]# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is ‘^]‘.
+OK [XCLIENT] Dovecot ready.
user student
+OK
pass student
-ERR [SYS/PERM] Permission denied
Connection closed by foreign host.
##权限不够
[[email protected] ~]# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is ‘^]‘.
+OK [XCLIENT] Dovecot ready.
user lee
+OK
pass lee
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.

==smtp连接mysql==
  107  yum install httpd php php-mysql -y
  108  yum instal lftp
  109  yum install lftp -y
  110  yum install mariadb-server.x86_64 -y
[[email protected] ~]# cd /var/www/html/
[[email protected] ~]# 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 25  2013 phpMyAdmin-2.11.3-all-languages.tar.bz2
-rwxr-xr-x    1 1000     1000      4548030 Dec 25  2013 phpMyAdmin-3.4.0-all-languages.tar.bz2
-rw-rw-r--    1 1000     1000      2713600 Jun 07  2015 taobao.tar
-rwxr-xr-x    1 1000     1000     52387876 Feb 01  2015 thunderbird-31.2.0-1.el7.x86_64.rpm
-rwxr-xr-x    1 1000     1000     36902724 Feb 01  2015 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
[[email protected] html]# ls
phpMyAdmin-3.4.0-all-languages.tar.bz2
[[email protected] html]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2
[[email protected] html]# ls
phpMyAdmin-3.4.0-all-languages  phpMyAdmin-3.4.0-all-languages.tar.bz2
[[email protected] html]# rm -fr phpMyAdmin-3.4.0-all-languages.tar.bz2
[[email protected] html]# mv phpMyAdmin-3.4.0-all-languages/ myadmin
[[email protected] html]# cd myadmin/
[[email protected] myadmin]# cp -p config.sample.inc.php config.inc.php
[[email protected] myadmin]# vim config.inc.php
 17 $cfg[‘blowfish_secret‘] = ‘westos‘; /* YOU MUST FILL IN THIS FOR COOKIE AU    TH! */
[[email protected] myadmin]# systemctl start httpd
[[email protected] myadmin]# systemctl start mariadb
[[email protected] myadmin]# mysql_secure_installation
密码:westos
[[email protected] myadmin]# systemctl restart mariadb
[[email protected] myadmin]# cd
[[email protected] ~]# firefox &
配置email库muser表4个字段
插入一行用户信息

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

[email protected] ~]# 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                       |
+------------------+----------+------------+-------------------------------+
| [email protected] | 123      | westos.org | /home/vmail/westos.org/admin/ |
+------------------+----------+------------+-------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> CREATE USER [email protected] identified by ‘postfix‘;
Query OK, 0 rows affected (0.00 sec)

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

MariaDB [(none)]> quit
Bye
[[email protected] ~]# 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                       |
+------------------+----------+------------+-------------------------------+
| [email protected] | 123      | westos.org | /home/vmail/westos.org/admin/ |
+------------------+----------+------------+-------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> quit

[[email protected] ~]# cd /etc/postfix/
[[email protected] 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
[[email protected] postfix]# postmap -q "[email protected]" mysql:/etc/postfix/mysql-users.cf
[email protected]
[[email protected] postfix]# vim mysql-domain.cf
  6 select_field = domain
  7 where_field = domain
[[email protected] postfix]# postmap -q "westos.org" mysql:/etc/postfix/mysql-domain.cf
westos.org
[[email protected] postfix]# vim mysql-maildir.cf
  6 select_field = maildir
  7 where_field = username
[[email protected] postfix]# postmap -q "[email protected]" mysql:/etc/postfix/mysql-maildir.cf
/home/vmail/westos.org/admin/

网页上添加一个lee用户

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

[[email protected] postfix]# groupadd vmail -g 666
[[email protected] postfix]# useradd -u 666 -g 666 -s /sbin/nologin vmail
[[email protected] postfix]# postconf -d | grep virtual
......    ##不要自己敲,尽量复制粘贴
[[email protected] postfix]# postconf -e "virtual_gid_maps = static:666"
[[email protected] postfix]# postconf -e "virtual_uid_maps = static:666"
[[email protected] postfix]# postconf -e "virtual_mailbox_base = /home/vmail"
[[email protected] postfix]# postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf"
[[email protected] postfix]# ll /etc/postfix/mysql-users.cf
-rw-r--r--. 1 root root 128 Dec  3 02:34 /etc/postfix/mysql-users.cf
[[email protected] postfix]# postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
[[email protected] postfix]# ll /etc/postfix/mysql-domain.cf
-rw-r--r--. 1 root root 124 Dec  3 02:37 /etc/postfix/mysql-domain.cf
[[email protected] postfix]# postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf"
[[email protected] postfix]# ll /etc/postfix/mysql-maildir.cf
-rw-r--r--. 1 root root 127 Dec  3 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字段
[[email protected] postfix]# 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           |
+------------------+----------+------------+-------------------+
| [email protected] | 123      | westos.org | westos.org/admin/ |
| [email protected]   | 123      | westos.org | westos.org/lee/   |
+------------------+----------+------------+-------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

[[email protected] ~]# mail [email protected]
Subject: test
test
.
EOT
[[email protected] ~]# mailq
Mail queue is empty

[[email protected] ~]# cd /home
[[email protected] home]# ls
lee  student  vmail  westos
[[email protected] home]# cd vmail
[[email protected] vmail]# ls
mail  westos.org            ##哪来的mail,应该只有westos.org
[[email protected] vmail]# cd westos.org/
[[email protected] westos.org]# ls
admin
[[email protected] westos.org]# cd admin
[[email protected] admin]# ls
cur  new  tmp

[[email protected] vmail]# cd /etc/dovecot/
[[email protected] dovecot]# ls
conf.d  dovecot.conf
[[email protected] dovecot]# cd conf.d/
[[email protected] 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.ext  auth-system.conf.ext
15-mailboxes.conf  auth-deny.conf.ext           auth-vpopmail.conf.ext
[[email protected] conf.d]# vim 10-auth.conf
122 !include auth-system.conf.ext
123 !include auth-sql.conf.ext
[[email protected] conf.d]# vim auth-sql.conf.ext
  8   # Path for SQL configuration file, see example-config/dovecot-sql.conf.e    xt
[[email protected] conf.d]# cd /usr/share/doc/dovecot-2.2.10/
[[email protected] dovecot-2.2.10]# ls
AUTHORS    COPYING.LGPL       dovecot-openssl.cnf  NEWS             wiki
ChangeLog  COPYING.MIT        example-config       README
COPYING    documentation.txt  mkcert.sh            solr-schema.xml
[[email protected] dovecot-2.2.10]# cd example-config/
[[email protected] example-config]# ls
conf.d        dovecot-dict-auth.conf.ext  dovecot-ldap.conf.ext
dovecot.conf  dovecot-dict-sql.conf.ext   dovecot-sql.conf.ext
[[email protected] example-config]# cp dovecot-sql.conf.ext /etc/dovecot/
[[email protected] example-config]# cd /etc/dovecot/
[[email protected] dovecot]# ls
conf.d  dovecot.conf  dovecot-sql.conf.ext
[[email protected] dovecot]# 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‘
[[email protected] dovecot]# cd conf.d/
[[email protected] conf.d]# vim 10-mail.conf
 30 mail_location = maildir:/home/vmail/%d/%n
168 first_valid_uid = 666
175 first_valid_gid = 666
[[email protected] conf.d]# systemctl restart dovecot.service
[[email protected] conf.d]# yum install telnet -y
[[email protected] conf.d]# 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.
[[email protected] conf.d]# tail -n 5 /var/log/maillog
发现
Dec  3 03:53:30 maillinux dovecot: auth: Fatal: Unknown database driver ‘mysql‘
[[email protected] conf.d]# 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.
[[email protected] conf.d]# yum install dovecot-mysql -y
......
[[email protected] conf.d]# systemctl restart dovecot.service

[[email protected] conf.d]# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is ‘^]‘.
+OK [XCLIENT] Dovecot ready.
user [email protected]
+OK
pass 123
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
[[email protected] conf.d]# telnet 172.25.254.215 110
Trying 172.25.254.215...
Connected to 172.25.254.215.
Escape character is ‘^]‘.
+OK [XCLIENT] Dovecot ready.
user [email protected]
+OK
pass 123
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.

使用雷鸟进行测试

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

    时间: 2024-10-09 16:13:27

    三.mail 接收权限 dovecot加密通信 php数据库 thunderbird的相关文章

    Security基础(三):OpenSSL及证书服务、邮件TLS/SSL加密通信

    一.OpenSSL及证书服务 目标: 本案例要求熟悉OpenSSL工具的基本使用,完成以下任务操作: 使用OpenSSL加密/解密文件 搭建企业自有的CA服务器,为颁发数字证书提供基础环境 方案: 使用两台RHEL7虚拟机,其中svr7作为CA数字证书服务器,而pc207作为测试用客户机. 步骤: 步骤一:使用OpenSSL加密/解密文件 1)加密文件 创建一个明文的文本文件f1.txt,使用openssl进行加密,选用des3加密算法,输出的加密文件为f1.txt.enc . [[email 

    邮件TLS/SSL加密通信

    案例1:邮件TLS/SSL加密通信 1 案例1:邮件TLS/SSL加密通信1.1 问题 本案例要求为基于Postfix+Dovecot的邮件服务器提供加密通信支持,主要完成以下任务操作: 为SMTP服务(postfix)添加TLS/SSL加密通信支持 基于dovecot配置POP3s+IMAPS加密通信支持 客户端收发信测试,确保加密的邮件通信可用 1.2 方案 使用两台RHEL7虚拟机,其中svr7作为CA服务器,而mail作为测试用的Postfix+Dovecot邮件服务器.另外可准备一台p

    Liunx 部署邮件TLS/SSL加密通信服务

    部署邮件TLS/SSL加密通信服务 一.部署普通邮件服务器 1) 搭建并检测邮件服务的发送服务 [[email protected] ~]# rpm -q postfix postfix-2.10.1-6.el7.x86_64 [[email protected] ~]# netstat -pantu | grep :25 tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1822/ma

    对Elastic集群配置TLS加密通信及身份验证

    1.介绍 官方宣布从6.8和7.1开始,免费提供多项安全功能.其中包括tls加密通信,基于角色访问控制等功能. 可以使用企业CA证书来完成这一步骤,但是一般情况下,我们可以通过elasticsearch自带的elasticsearch-certutil的命令生成证书.然后各节点通过该证书可以进行安全通信. 2. 步骤 2.1 生成证书 搭建好了es集群,先拿第一个节点来操作,进入elasticsearch目录,然后执行以下命令. cd /usr/share/elasticsearch # 使用y

    开源项目SMSS发开指南(四)——SSL/TLS加密通信详解

    本文将详细介绍如何在Java端.C++端和NodeJs端实现基于SSL/TLS的加密通信,重点分析Java端利用SocketChannel和SSLEngine从握手到数据发送/接收的完整过程.本文也涵盖了在Ubuntu系统上利用OpenSSL和Libevent如何创建一个支持SSL的服务端.文章中介绍的知识点并未全部在SMSS项目中实现,因此笔者会列出所有相关源码以方便读者查阅.提醒:由于知识点较多,分享涵盖了多种语言.预计的学习时间可能会大于3小时,为了保证读者能有良好的学习体验,继续前请先安

    HTTPS加密通信原理及数字证书系统

    https加密通信原理: 公钥私钥成对,公钥公之于众,私钥只有自己知道. 用公钥加密的信息只能由与之相对应的私钥解密. 甲给乙发送数据时,甲先用乙的公钥加密这段数据,再用自己的私钥对这段数据的特征数据(数字指纹,通过HASH函数生成)进行RSA运算形成签名.乙接到数据后,先用自己的私钥解密数据,并用甲的公钥对甲的签名进行验证(解出数字指纹,与接收到的数据的数字指纹做对比).如此,可保证发信人无法抵赖曾发过该信息,也确保报文在传递过程中不会被篡改. CA证书: CA证书是指CA颁发给用户的证书,其

    bugzilla4的xmlrpc接口api调用实现分享: xmlrpc + https + cookies + httpclient +bugzilla + java实现加密通信下的xmlrpc接口调用并解决登陆保持会话功能

    xmlrpc .  https . cookies . httpclient.bugzilla . java实现加密通信下的xmlrpc接口调用并解决登陆保持会话功能,网上针对bugzilla的实现很少,针对xmlrpc的有但是基本都是http协议的,https下的认证处理比较麻烦,而且会话保持也是基本没有太多共享,所以本人决定结合xmlrpc\bugzilla官方文档,网友文章,结合个人经验总结而成,已经在window2007 64+jdk7位机器上调试通过 手把手教你如何实现: 第一步: 在

    Android BLE与终端通信(三)——client与服务端通信过程以及实现数据通信

    Android BLE与终端通信(三)--client与服务端通信过程以及实现数据通信 前面的终究仅仅是小知识点.上不了台面,也仅仅能算是起到一个科普的作用.而同步到实际的开发上去,今天就来延续前两篇实现蓝牙主从关系的client和服务端了.本文相关链接须要去google的API上查看,须要FQ的 Bluetooth Low Energy:http://developer.android.com/guide/topics/connectivity/bluetooth-le.html 可是我们依旧

    一个加密通信过程

    公钥密码体制(public-key cryptography) 公钥密码体制分为三个部分,公钥,私钥,加密解密算法. 加密:通过加密算法和公钥对内容(也称明文)进行加密,得到密文.加密过程要用到公钥. 解密:通过解密算法和公钥对密文进行解密,得到明文.解密过程需要用到私钥 由公钥加密的内容,只能由私钥解密:由私钥加密的内容,只能由公钥解密. 对称加密算法(symmetric key algorithms) 解密与加密使用密钥是相同的 非对称加密算法(asymmetric key algorith