三.mail 接收权限 dovecot加密通信 php数据库 thunderbird
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了三.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] ~]# 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.
使用雷鸟进行测试
注册一个新的邮箱,发一封邮件,是给你建立邮件目录
本文出自 “12100661” 博客,谢绝转载!
以上是关于三.mail 接收权限 dovecot加密通信 php数据库 thunderbird的主要内容,如果未能解决你的问题,请参考以下文章
dovecot并发数造成foxmailoutlook等客户端工具接收邮件有时候报错