SMTP Virtual user mail transfer and management
I. Local administration of Simple Mail transfer
1). How this machine denies other designated IP hosts to send mail remotely
Server configuration: (The restriction rules are in the order of the query, the first rule that meets the criteria is executed)
Vim/etc/postfix/access
(IP) 172.25.254.***REJECT
Postmap/etc/postfix/access
Postconf-e "Smtpd_client_restrictions =check_client_access hash:/etc/postfix/access"
Systemctl Restart Postfix.service
Test remote Send mail
Telnet IP
Mail From:[email protected]
RCPT To:[email protected]
If a message is sent remotely, the client's IP address matches the IP in Access and denies the client's connection request)
2). How to deny other users remote access to send mail
Vim/etc/postfix/sender
[Email protected] REJECT(Note: Remote access is a domain-wide deny)
Postmap/etc/postfix/sender
Postconf-e "smtpd_sender_restrictions = check_sender_access Hash:/etc/postfix/sender"
Systemctl Restart Postfix.service
3). How to specify that users cannot receive remote Mail
Vim/etc/postfix/recip
[Email protected] REJECT
Postmap Recip
Postconf-e "Smtpd_recipient_restrictions =check_recipient_access Hash:/etc/postfix/recip"
Systemctl Restart Postfix.service
Two. Receipt of Simple Mail (remote receive (DOVECOT) management)
1) Yum Install Dovecot-y
View the interface for the message types supported by the Dovecot (Dovecot can open four ports)
IMAP143cat/etc/services | grep IMAP
Popcat/etc/services | grep imaps
Imaps993cat/etc/services | grep POP3
Pop3s995cat/etc/services | grep pop3s
2) vim/etc/dovecot/dovecot.conf
24| protocols = IMAP POP3 LMTP*/Postal Transport protocol LMTP is local transfer
48| Login_trusted_networks = 0.0.0.0/0
49| Disable_plaintext_auth = no/* Allow plaintext password authentication
Vim/etc/dovecot/conf.d/10-mail.conf
Mail_location = mbox:~/mail:inbox=/var/mail/%u/* Local mail location
Systemctl Start Dovecot
Netstat-antlpe | grep dovecot/* View Dovecot Ports
Yum Install Mutt-y
>/var/log/maillog
Tail-f/var/log/maillog/* Email error message
Mutt-f Pop://[email protected]
Direct Access will be an error, there is no/home/westos/mail/.imap this directory
Su-westos
CD Mail
Ls-a
mkdir. IMAP
Touch/home/westos/mail/.imap/inbox
If you want to set up the above directories automatically, you need to establish mkdir-p under/etc/skel mail/.imap
Touch/etc/skel/mail/.imap/inbox
3). Install software management Dovecot, Thunderbird software (there are two ways to install Thunderbird, one is to write a script, step-by-step installation, and the other is to create a third-party yum Source
)
1) Create a script
#!/bin/bash
Yum Whatprovide */$1
./thunderbird (performing Thunderbird can view missing plugins) Execute scripts to look for software that needs to be installed to solve Thunderbird dependencies
Three. Create a virtual user and database association for Simple Mail
1) First make PHP software management mariadb
Yum Install Mariadb-y
Yum Install Mariadb-server-y
Yum intsall php php-mysql-y/*php is a scripting language embedded in HTML and interpreted by the server
Tar jxf phpmyadmin-3.4.0-all-languages.tar.bz2-c/var/www/html
Yum Install Phpmyadmin-3.4.0-all-languages-y
CP config.sample.inc.php config.inc.php
Vim config.inc.php
$cfg [' blowfish_secret '] = ' westos ';
Systemctl Restart httpd/* Note: If you do not restart properly, modify the contents of the hosts, plus local DNS and domain names
2) Install the database to make the following settings
Mysql-uroot-pwestos
SELECT * from Email.muser;
Create user [email protected] identified by ' postfix '
Grant Insert,upddate,select on email.* to [email protected];
Mysql-upostfix-ppostfix
SELECT * from Email.muser;
3) Edit the file name, user name, mail location
Cd/etc/postfix
Vim MYSQL-USERS.CF
hosts = localhost
user = Postfix
Password = postfix
dbname = Email
Table = Muser
Select_field = Username
Where_field = Username
Postmap-q "[email protected]" MYSQL:/ETC/POSTFIX/MYSQL-USERS.CF
Cp-p mysql-users.cf MYSQL-DOMAIN.CF
Modify the last two items
Select_field = Domain
Where_field = Domain
Postmap-q "linux.org" mysql:/etc/postfix/mysql-domain.cf
Cp-p mysql-users.cf MYSQL-MAILDIR.CF
Modify the last two items
Select_field = Maildir
Where_field = Username
Postmap-q "[email protected]" MYSQL:/ETC/POSTFIX/MYSQL-MAILDIR.CF
4) Set up account management virtual user
Useradd-u 666-g 666 vmail-s/sbin/nologin
Groupadd-g 666 Vmail
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"
Postconf-e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
Postconf-e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf"
5) Associating virtual users with Postfix
cd/usr/share/doc/dovecot-2.2.10/
CD Example-config
CP Dovecot-sql.conf.ext/etc/dovecot
Vim/etc/dovecot/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 '
Vim/etc/dovecot/conf.d/10-mail.conf
30|mail_location = maildir:/home/vmail/%d/%n
168|first_valid_uid = 666
175|first_valid_gid = 666
Vim/etc/dovecot/conf.d/10-auth.conf
122|! Include Auth-systemctl.conf.ext/* Real users can log in
123|! Include Auth-sql.conf.ext/* Allow virtual users to log in
Yum Install Dovecot-mysql.x86_64-y
Iv. empty Shell e-mail server
Vim/etc/named.rfc1912.zones
Znoe "Linux.org" in {
Type master;
File "Linux.org.zone"
allow-update {none;};
};
Vim/var/named/linux.org.zone
Linux.org. MX 1 172.25.254.150.
Rm-fr/etc/postfix/main.cf
Yum Reinstall postfix-y
Vim/etc/postfix/main.cf
75|myhostname = mail.mail.com
83|mydomain = mail.com
98|myorigin = linux.org
113|inet_interfaces = All
164|mydestination =
313|relayhost = 172.25.254.249
140|local_transport = error:local Delivery disabled
MyNetwork = 172.25.254.0/24
Testing on the core processing mail server: Cd/home/vmail
Watch-n 1 ls//production look for sent messages
Virtual User Mail Transfer