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

Email

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

# email#

Basic email delivery

Send e-mail

1. The server submits the email to TCP port 25 using the SMTP protocol or by the local client through the / usr/bin/sendmail program. If the MTA is the final destination, the message is delivered to MDA. Otherwise, the MX record is used to find the next MTA in DNS and SMTP is used to forward it.

2. MDA: "Mail sending agent". MDA sends the message to the recipient's local mail storage location (/ var/spool/mail/user by default). Postfix provides its own MDA to send to the default file-based local mail storage location / usr/libexec/postfix/local.

3. Forwarding: the e-mail server (MTA) forwards the submitted message to another server for delivery

4. Queuing: failed send or forward attempts are queued and retried as defined by MTA. (by default, Postfix does this once an hour)

5. Reject: e-mail is rejected by the e-mail server during the first submission

6. Bounce: after the remote server accepts the email for delivery, it returns the email to the originating email server and / or the user

7. After the e-mail has been sent, the e-mail is returned to the originating email server and / or the user for preparation:

# prepare: #

One: desktop virtual machine (westos-mail.westos.com)

# configure the network. Yum source. Modify host name

88 cd / etc/sysconfig/network-scripts/

89 ls

90 vim ifcfg-eth0

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

IPADDR=172.25.254.144

NETMASK=255.255.255.0

104 hostnamectl set-hostnamewestos-mail.westos.com

105 logout

107 vim / etc/yum.repos.d/rhel_dvd.repo

108 yum clean all

# configure DNS

109 yum install bind-y

111 systemctl start named

114 vim / etc/named.conf

115 vim / etc/named.rfc1912.zones

116 cd / var/named

117 ls

118 cp-p named.localhostwestos.com.zone

119 vim westos.com.zone

120 cp-p westos.com.zoneqq.com.zone

121 vim qq.com.zone

122 systemctl restart named

131 systemctl stop firewalld

# Test:

123 vim / etc/resolv.conf

124 cd

126 dig dns.westos.com

136 dig-t mx westos.com

Two: server virtual machine (qq-mail.qq.com)

# configure the network. Yum source. Modify host name

1 cd/etc/sysconfig/network-scripts/

2 ls

3 vim ifcfg-eth0

4 vim / etc/yum.repos.d/rhel_dvd.repo

5 yumclean all

6 hostnamectl set-hostname qq-mail.qq.com

7 logout

# Test:

20 vim / etc/resolv.conf

21 dig dns.qq.com

22 dig-t mx qq.com

# # #

# postfix #

1.

Postfix provides smtp protocol for delivering mail.

Default port 25

/ var/log/maillog # # Service Log

Mail root@westos.com

Subject: hello

Hello world

. # use "." To end the entry and send

Mailq # # View message queues

Postqueue-f # # reprocess the mail queue

By default, the mail port is only open on 127.0.0.1.

two。 Configure both virtual machines

All of the following instructions can be found in the / etc/postfix/main.cf file.

(1) myorigin

Rewrite locally published e-mail messages so that they appear to be from this domain. This helps ensure that the response is returned to the inbound mail server by default: myorigin = $myhostname

(2) inet_interfaces

Controls the network interface on which Postfix listens for incoming e-mail. If set to loopback-only, only listen for 127.0.0.1 and:: 1

If set to all, listen on all network interfaces. You can also specify a specific address.

Default: inet_interfaces = localhost

(3) mydestination

Emails received at these domains are delivered to MDA for local delivery.

Default: mydestination = $myhostname, localhost.$mydomain,localhost

(4) mynetworks

A comma-separated list of IP addresses and networks (in CIDR notation). These addresses and networks can be forwarded to the

Any location without further authentication.

Default: mynetworks = 127.0.0.0Comp8

(5) relayhost

Relayhost forwards all outbound messages that pass through. It is usually specified in square brackets to prevent MX record lookups.

Default: relayhost = local_transport

How to send a message with a pickup address of $mydestination. By default, it is set to local:$myhostname (use Local MDA to send incoming email to the local mail storage location in / var/spool/mail)

Default: local_transport = local:$myhostname

(6) postconf-d displays the default value.

(7) postconf-n displays changes that are different from the default values.

# westos.com:

Vim / etc/postfix/main.cf

116 inet_interfaces = all # # Network interface opened on port 25

76 myhostname = westos-mail.westos.com # # specify the mta host name

83 mydomain = westos.com # # specify the domain name of mta

99 myorigin = westos.com/$mydomain # # specifies the end of the message source (the character content after @)

164For mydestination = $myhostname, $mydomain, localhost # # specify the end character of the received mail

Systemctl restart postfix.service

Systemctl stop firewalld

28 vim / etc/postfix/main.cf

29 systemctl restart postfix.service

30 systemctl stop firewalld

# qq.com:

Vim / etc/postfix/main.cf

116 inet_interfaces = all # # Network interface opened on port 25

76 myhostname = qq-mail.qq.com # # specify the mta host name

83 mydomain = qq.com # # specify the domain name of mta

99 myorigin = qq.com/$mydomain # # specifies the end of the message source (the character content after @)

164For mydestination = $myhostname, $mydomain, localhost # # specify the end character of the received mail

Systemctl restart postfix.service

Systemctl stop firewalld

8 vim / etc/postfix/main.cf

9 systemctl restartpostfix.service

10 systemctl stop firewalld

Test: can email each other

31 mail root@qq.com

32 mailq

33 mail

11 mail

12 mail root@westos.com

13 mailq

3. Mail alias

[root@qq-mail ~] # vim / etc/aliases

Alias: real name # # email alias

Alias:: include:filename # # send mass mail

Vim filename

User1

User2

Postalias / etc/aliases

Mail alias

39 vim / etc/aliases # profile

40 vim / etc/postfix/qun

41 postalias / etc/aliases # encryption

42 systemctl restart postfix.service

43 mail qun@westos.com # mass email

44 mailq

45 mail

46 mail-u student

47 mail admin@westos.com # root alias admin

48 mailq

49 mail

50 mail admiin@westos.com # student alias admiin

51 mailq

52 mail-u student

4. Test the mail service through a remote host

Real machine:

[root@foundation44 ~] # yum install telnet.x86_64-y

[root@foundation44 ~] # telnet 172.25.254.144 25

Trying 172.25.254.144...

Connected to 172.25.254.144.

Escape character is'^]'.

220 westos-mail.westos.com ESMTP Postfix

Ehlo hello # determine if the software is installed

250-westos-mail.westos.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

Mail from:root@westos.com # sender

250 2.1.0 Ok

Rcpt to:root@qq.com # recipient

250 2.1.5 Ok

Data # Editing email content

354 End data with.

Fhylkhhiplu.kj

.

250 2.0.0 Ok: queued as 4CF3617E86E

Quit # exit

221 2.0.0 Bye

Connection closed by foreign host.

[root@foundation44 yum.repos.d] #

Detect:

(1) westos.com sender

[root@westos-mail ~] # mailq

-Queue ID- Size-- Arrival Time-----Sender/Recipient-

52431246202 194 Tue May 2301:48:23 root@westos.com

(connect to172.25.254.244 [172.25.254.244]: 25: No route to host)

Root@qq.com

-- 0 Kbytes in 1 Request.

[root@westos-mail ~] # postqueue-f # # reprocess the mail queue

[root@westos-mail ~] # mailq

Mail queue is empty

[root@westos-mail ~] #

(2) qq.com recipient

[root@qq-mail ~] # mail

Heirloom Mail version 12.5 7-5-10. Type? For help.

"/ var/spool/mail/root": 3 messages 2 new 3 unread

U 1 root Tue May 2300 05 22 Compact 734 "qqqq"

N 2 root@westos.com Tue May 23 01:52 14 amp 494

N 3 root@westos.com Tue May 2301:53 15/497

& quit

Held 3 messages in / var/spool/mail/root

You have mail in / var/spool/mail/root

[root@qq-mail ~] #

5. Access control of mail client

# restrict clients

In westos.com:

Postconf-e "smtpd_client_restrictions = check_client_accesshash:/etc/postfix/access" # generate the contents of / etc/postfix/main.cf file

Vim / etc/postfix/main.cf

Vim / etc/postfix/access

172.25.254.44 REJECT

Postmap / etc/postfix/access # encryption / etc/postfix/access

Systemctl restart postfix # restart postfix

Test: real machine

[root@foundation44 ~] # telnet 172.25.254.144 25

Trying 172.25.254.144...

Connected to 172.25.254.144.

Escape character is'^]'.

220 westos-mail.westos.com ESMTP Postfix

Mail from:root@westos.com # sender

250 2.1.0 Ok

Rcpt to:root@qq.com # recipient

554 5.7.1: Client host rejected: Accessdenied

# restrict users from sending

[root@westos-mail ~] # postconf-e "smtpd_sender_restrictions = check_sender_accesshash:/etc/postfix/sender"

[root@westos-mail ~] # vim / etc/postfix/main.cf

[root@westos-mail ~] # vim / etc/postfix/sender

Student@westos.com REJECT

[root@westos-mail ~] # cd / etc/postfix

[root@westos-mail postfix] # ls

Access canonical header_checks master.cf relocated sender.db virtual

Access.db generic main.cf qun sender transport

[root@westos-mail postfix] # systemctl start named

[root@westos-mail postfix] # systemctl restart postfix

Test:

[root@foundation44 ~] # telnet 172.25.254.144 25

Trying 172.25.254.144...

Connected to 172.25.254.144.

Escape character is'^]'.

220 westos-mail.westos.com ESMTP Postfix

Mail from:student@westos.com

250 2.1.0 Ok

Rcpt to:root@qq.com

554 5.7.1: Sender address rejected: Accessdenied

# restrict users from receiving

[root@westos-mail ~] # postconf-e "smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/recip"

[root@westos-mail ~] # vim / etc/postfix/main.cf

[root@westos-mail ~] # vim / etc/postfix/recip

Westos@westos.com REJECT

[root@westos-mail ~] # postmap / etc/postfix/recip

[root@westos-mail ~] # systemctl restart postfix

[root@westos-mail ~] # useradd westos

[root@westos-mail ~] #

Test:

[root@foundation44 ~] # telnet 172.25.254.144 25

Trying 172.25.254.144...

Connected to 172.25.254.144.

Escape character is'^]'.

220 westos-mail.westos.com ESMTP Postfix

Mail from:westos@westos.com

250 2.1.0 Ok

Rcpt to:westos@westos.com

554 5.7.1: Sender address rejected: Accessdenied

Quit

221 2.0.0 Bye

Connection closed by foreign host.

# Enterprise mailbox

# de-stack address translation

1 postconf-d | grep generic

2 postconf-e "smtp_generic_maps = hash:/etc/postfix/generic"

3 vim / etc/postfix/main.cf

4 vim / etc/postfix/generic

Westos@westos.com hello@sb.com

True domain name fake domain name

5 postmap / etc/postfix/generic

6 systemctl restart postfix

7 su-westos

Test: [westos@westos-mail ~] $history

1 mail root@qq.com

2 mailq

[root@qq-mail ~] # mail

# # War address Translation

1. Dns mx record parsing is done first.

17 vim / etc/named.rfc1912.zones

18 cp-p qq.com.zone sb.com.zone

19 vim sb.com.zone

20 systemctl restart named

21 dig-t mx sb.com

two。

26 postconf-e "virtual_alias_maps = hash:/etc/postfix/virtual"

27 vim / etc/postfix/main.cf

28 vim / etc/postfix/virtual

Virtual name, real user.

Hello@sb.com westos@westos.com

29 postmap / etc/postfix/virtual

30 systemctl restart postfix

31 su-westos

Test:

[root@qq-mail ~] # mail hello@sb.com

[westos@westos-mail ~] $mail

# #

# dovecot #

# #

1.

Dovecot is used to provide pickup protocols.

Pop3 110

Imap 143

Imaps 993

Pop3s 995

Given the user name and password, the dovecot program looks at the user's mail file on our behalf.

# receive email #

two。

Yum install dovecot-y

Systemctl start dovecot

Netstat-antlpe | grep dovecot

3.

Vim / etc/dovecot/dovecot.conf

24 protocols = imap pop3 lmtp

48 login_trusted_networks = 0.0.0.0amp 0

49 disable_plaintext_auth = no

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

30 mail_location = mbox:~/mail:INBOX=/var/mail/%u # # prevent others from receiving your email

Passwd westos #

Mail westos

4.

[root@westos-mail ~] # su-westos

[westos@westos-mail] $mkdir mail/.imap/-p

[westos@westos-mail ~] $touch mail/.imap/INBOX

[westos@westos-mail ~] $logout

5. Automatically compose mail/.imap

Mkdir / etc/skel/mail/.imap/-p

Touch / etc/skel/mail/.imap/INBOX

/ etc/skel # Skeleton directory

14 mkdir / etc/skel/mail/.imap/-p

15 touch / etc/skel/mail/.imap/INBOX

16 useradd lee

17 cd / home/lee

18 ll

19 ls mail/-a

20 ls mail/.imap/INBOX

21 passwd lee

22 mail lee

test

Real machine:

[root@foundation44 ~] # yum install mutt-y

[root@foundation44 ~] # mutt-fpop://westos@172.25.254.144

2 kept, 0 deleted.

[root@foundation44 ~] # mutt-fpop://lee@172.25.254.144

1 kept, 0 deleted.

Select O

Enter password

Press Enter

# Thunderbird #

1 download thunderbird-31.2.0-1.el7.x86_64.rpm

2 installation

Yum install / home/kiosk/Desktop/thunderbird-31.2.0-1.el7.x86_64.rpm-y

3 (1) Open Thunderbird

(2)

4 Verification:

[root@qq-mail ~] # mail

# mariadb;dovecot;postfix#

one

Preparatory work:

(1) # postfix###

Westos.com:

201 mv / etc/postfix/main.cf / mnt/

202 yum reinstall postfix-y

203 vim / etc/postfix/main.cf

116 inet_interfaces = all # # Network interface opened on port 25

76 myhostname = qq-mail.qq.com # # specify the mta host name

83 mydomain = qq.com # # specify the domain name of mta

99 myorigin = qq.com/$mydomain # # specifies the end of the message source (the character content after @)

164For mydestination = $myhostname, $mydomain, localhost # # specify the end character of the received mail

204 systemctl restart postfix

(2) # mariadb####

205 yum install http php php-mysql mariadb-server-y

206 systemctl start mariadb

208vim / etc/my.cnf # configuration file for mysqul

14 skip-networking=1

209 systemctl restart mariadb # restart mariadb service

210 mysql_secure_installation # mysql secure content configuration

All press enter.

download

215 scproot@172.25.254.44:/home/kiosk/Desktop/phpMyAdmin-3.4.0-all-languages.tar.bz2 / var/www/html

# download the zip file

216 cd / var/www/html

217 ls

218 tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2

# decompress the package to / var/www/html

219 ls

220 rm-fr * .bz2

221 ls

222 mv phpMyAdmin-3.4.0-all-languages/ mysqladmain # move all files under the installation package to mysqladmin

223 cd mysqladmain/

224 ls

225 cp config.sample.inc.php config.inc.php # copy configuration file

226 vim config.inc.php # write configuration file

$cfg ['blowfish_secret'] =' mysql'; / * YOU MUST FILL IN THIS FOR COOKIE Auth requests /

227 systemctl restart httpd

Real machine:

Open a browser to access: http://172.25.254.144/myadmin/

Westos.com:

228 mysql-uroot-pqwer

MariaDB [(none)] > create userpostuser@localhost identified by 'postuser'; # set up postuser users and log in locally

MariaDB [(none)] > grantselect,update,insert on email.* to postuser@localhost; # Log in to postuser locally and authorize

MariaDB [(none)] > select * fromemail.emailuser;### queries all the contents of the email.emailuser table

MariaDB [(none)] > quit

Test:

32 cd / etc/postfix

34 vim mailuser.cf # user name query

Hosts = localhost # the host where the database is located

User = postuser # users who log in to the database

Password = postuser # password to log in to the database

Dbname = email # postfix the name of the query

Table = emailuser # postfix the name of the table to query

Select_field = username # fields to be queried by postfix

Where_field = username # query conditions for the postfix given by the user

35 postmap-Q "lee@lee.com" mysql:/etc/postfix/mailuser.cf

36 cp mailuser.cf maildomain.cf

37 vim maildomain.cf # user domain name query

Hosts = localhost

User = postuser

Password = postuser

Dbname = email

Table = emailuser

Select_field = domain

Where_field = domain

38 postmap-Q "lee.com" mysql:/etc/postfix/maildomain.cf

39 cp mailuser.cf mailbox.cf

40 vim mailbox.cf # query the location of users' mailboxes

Hosts = localhost

User = postuser

Password = postuser

Dbname = email

Table = emailuser

Select_field = maildir

Where_field = username

41 postmap-Q "lee@lee.com" mysql:/etc/postfix/mailbox.cf

42 ls

43 cat mailuser.cf

44 cat maildomain.cf

45 cat mailbox.cf

46 history

2 # # configure postfix

[root@westos-mail] # groupadd-g 666 vmail

[root@westos-mail] # useradd-s / sbin/nologin-u 666 vmail-g 666

[root@westos-mail ~] # id vmail

Uid=666 (vmail) gid=666 (vmail) groups=666 (vmail)

[root@westos-mail ~] # postconf-e "virtual_mailbox_base = / home/vmail"

# # setting the email directory of virtual users

[root@westos-mail ~] # postconf-e "virtual_uid_maps = static:666"

# # uid of files created by virtual users

[root@westos-mail ~] # postconf-e "virtual_gid_maps = static:666"

# # gid of files created by virtual users

[root@westos-mail ~] # postconf-e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"

[root@westos-mail ~] # postconf-e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf"

[root@westos-mail ~] # postconf-e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"

[root@westos-mail ~] # vim/etc/postfix/main.cf

[root@westos-mail ~] # systemctl restartpostfix

[root@westos-mail ~] # ll/etc/postfix/mailbox.cf

-rw-r--r--. 1 root root 134 May 23 09:05 / etc/postfix/mailbox.cf

[root@westos-mail ~] # ll / etc/postfix/mailuser.cf

-rw-r--r--. 1 root root 135 May 23 09:03 / etc/postfix/mailuser.cf

[root@westos-mail ~] # ll / etc/postfix/maildomain.cf

-rw-r--r--. 1 root root 131 May 23 09:04 / etc/postfix/maildomain.cf

Modify mailbox location

Test:

[root@westos-mail ~] # cd / home/vmail

[root@westos-mail vmail] # ls

[root@westos-mail vmail] # mail lee@lee.com

Subject: abcd

Abcd

.

EOT

[root@westos-mail vmail] # ls

Lee.com

[root@westos-mail vmail] # cd lee.com

[root@westos-mail lee.com] # ls

Lee

[root@westos-mail lee.com] # cd lee

[root@westos-mail lee] # ls

Cur new tmp

[root@westos-mail lee] # catnew/1495545556.Vfd01I1a9eecdM433309.westos-mail.westos.com

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

Servers

Wechat

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

12
Report