Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[supplementary record of SMTP]

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

[supplementary record of STMP]

one。

1) [prohibit specified ip remote STMP operations on me]

Cd / etc/postfix/

Vim access [add as follows on the last line]

172.25.254.60 REJECT

Postmap access [refresh file] [at this time, there will be more than one access.db file in this directory] [postconf-d | grep client, you can view the parameters]

Postconf-e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access" [under / etc/postfix

The last parameter instruction to retrieve the access file is added to the mian.cf (main configuration file)]

Systemctl restart postfix [restart]

[test] send email with 172.25.254.60, mail from:student@hxl.com rcpt to:root@hxl.com; "554 5.7.1: Client hostrejected: Access denied" indicates success.

[undo the ban, delete the things added to the access file, refresh the file, restart the service]

2) [prohibit the STMP sending operation of the specified ip to the specified user]

Vim sender [create this directory under / etc/postfix/]

Student@hxl.com REJECT

Postconf-e "smtpd_sender_restrictions = check_sender_accesshash:/etc/postfix/sender" [under / etc/postfix

The last parameter instruction to retrieve the sender file is added to the mian.cf (main configuration file)]

Systemctl restart postfix [restart]

[test] in telnet, the sender sends it with student, and the error is "Sender address rejected: Access denied".

3) [prohibit the STMP pickup operation of the specified ip remote to the specified user]

Vim recip

Student@hxl.com REJECT

Postmap recip

Postconf-e "smtpd_recipient_restrictions = check_recipient_accesshash:/etc/postfix/recip"

Systemctl restart postfix

[test]

: Recipient address rejected: Access denied [normal]

two。

1.) [Dovecot mail server, providing services to these mail ports, imap143,pop3 110 imaps 993 and pop3s 995. Can cat / etc/services | grep imap/pop view]

Yum install dovecot-y

Vim / etc/dovecot/dovecot.conf [modify configuration file]

24 protocols = imap pop3 lmtp [interface to allow service]

49 disable_plaintext_auth = no [allow plaintext password authentication]

Vim / etc/dovecot/conf.d/10-mail.conf

22 mail_location = mbox:~/mail:INBOX=/var/mail/%u

Netstat-antlpe | grep dovecot [check whether port 993995110143 is open]

Yum install mutt-y [download an email program] [this operation is done on another host to see if you can receive mail with the Dovecot server installed]

Mutt-f pop3://student@172.25.254.161 [enter operation a] [in this operation, several files should be created in the stdent directory first]

[detailed file creation operation]

(1) mkdir / home/student/mail/.imap/-p

(2) touch / home/student/mail/.imap/INBOX

[when creating a new user, the user's home directory file is copied from / etc/skel/, under root by default. If you need many users to have these files, write them here once and for all. ]

[done, now execute mutt and you can see the mail received by student]

2.) [use email applications to send and receive mail remotely]

[front: download and install thunderbird-31.4.0.tar.bz2 on a host different from the above two. This is an available directory. After tar jxf ~ is decompressed, execute. / thunderbird in the thunderbird/ directory. Follow the prompts to query the installation package (yumwhatProvides ~) in turn and install it. There are more than ten of these. Slowly install and install, you will have a graphical interface tool.

Vim / etc/dovecot/dovecot.conf [modify configuration file]

48 login_trusted_networks= 0.0.0.0amp 0 [messages allowed for ip segments]

[users who configure the graphical interface add]

Because it is a local user, the name is the local user name: student; email student@hxl.com

Pickup: IMAP 172.25.254.161; Port: 143scape SSL: none; Authentication: ordinary password

Mailing: SMTP 172.25.254.161; Port: 25: SSL: none; Authentication: ordinary password

User name: student

[redetermine, confirm; can be received now]

3.*) [use the database, establish virtual users, and specify the receiving address of all users as / home/vmail/, to send and receive email]

[front: yum install mariadb-server-ytwityum install httpd;tarjxf phpMyAdmin-~.tar.bz2, change the name to myadmin, put it under / var/www/html/, enter the directory, cp config.sample.inc.php config.inc.php,vim the file, and add an arbitrary value of COOKIE; initial database information (mysql_secure_installation); add the initial ip and the corresponding domain name to / etc/hosts]

1. Create an information table in the database

Establish database in graphic application: email, data structure item: username,password,domain,maildir. All types are: varchar, length: 50 50 50 100

Create a table: muser table. (example) username:admin@hxl.org;password:123;domain:hxl.org;mkdir:/hxl.org/admin/

two。 Create a user (character interface) in the database and authorize

CREATE USER postfix@localhostidentified by 'postfix'

GRANT INSERT,UPDATE,SELECT on email.*to postfix@localhost

3. Fill in the configuration file about filtering information (cd / etc/pistfix/)

* vim mysql-users.cf

1.host = localhost

2.user = postfix

3.password = postfix

4.dbname = email

5.table = muser

6.select_field = username

7.where_field = username

[test]

Postmap-Q "admin@hxl.org" mysql:/etc/postfix/mysql-users.cf

Admin@hxl.org

* vim mysql-domain.cf

1.host = localhost

2.user = postfix

3.password = postfix

4.dbname = email

5.table = muser

6.select_field = domain

7.where_field = domain

[test]

Postmap-Q "hxl.org" mysql:/etc/postfix/mysql-domain.cf

Hxl.org,hxl.org

* vim mysql-maildir.cf

1.host = localhost

2.user = postfix

3.password = postfix

4.dbname = email

5.table = muser

6.select_field = maildir

7.where_field = username

[test]

Postmap-Q "admin@hxl.org" mysql:/etc/postfix/mysql-maildir.cf

Hxl.org/admin/

4. Add virtual users to the item main configuration file, as well as the above information

Set up a local user vmail, specify uip 888, and be in non-interactive mode

Groupadd-g 888 vmail

Useradd-g 888-u 888-s/sbin/nologin vmail

[add information to the main configuration file (/ etc/postfix/main.cf)]

Postconf-e "virtual_gid_maps = static:888"

Postconf-e "virtual_uid_maps = static:888"

Postconf-e "virtual_mailbox_base= / home/vmail"

Postconf-e "virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf"

Postconf-e "virtual_alias_maps = mysql:/etc/postfix/mysql-domain.cf"

Postconf-e "virtual_alias_maps = mysql:/etc/postfix/mysql-maildir.cf"

[test]

Mail admin@hxl.org [send an email to the ip]

Enter / home/vmail/admin and check the new directory in the file. Viewing the file in new is the message you sent, which means it is successful.

5. Configure dovecot Mail acceptance Service

Vim auth-sql.conf.ext [View sample file / usr/share/doc/dovecot-2.2.10/example-config]

Cp dovecot-sql.conf.ext/etc/dovecot/

Vim / etc/dovecot/dovecot-sql.conf.ext [configuration file, modified as follows]

31 # Database driver: mysql, pgsql,sqlite

32 driver = mysql

71 connect = host=localhost dbname=emailuser=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, 888 AS uid,888 AS gid FROM muser WHERE usernam e ='% u'

Vim / etc/dovecot/conf.d/10-mail.conf1

30 mail_location = maildir:/home/vmail/%d/%n

168 first_valid_uid = 888

175 first_valid_gid = 888

Systemctl restart dovecot.service [restart service]

Yum install dovecot-mysql

[test]

Remote telnet172.25.254.161

Useradmin@hxl.org

Pass 123

If the remote test is successful, you can use the service application to test.

Because it is a virtual user in the database, the name is the local user name: admin@hxl.org; email admin@hxl.org

Pickup: IMAP 172.25.254.161; Port: 143scape SSL: none; Authentication: ordinary password

Mailing: SMTP 172.25.254.161; Port: 25ssSSL: none; authenticated ordinary password

User name: admin@hxl.org [you can create a few more users in the database, send them to each other, and OK if you successfully accept them]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report