Use postfix to send emails between different CIDR blocks

Source: Internet
Author: User
Tags imap dovecot nameserver squirrelmail

Preface: since the 21st Century, emails played a more important role by writing letters to achieve communication between different regions. The emergence of the Internet greatly reduced the reception time, how to Set up an email server to allow real-time conversations? in linux, postfix is used.

Tutorial preparation: Disable SELinux and configure the yum source IP address

Lab environment: RHEL5.5

The lab uses at least three machines, one of which acts as a router to forward data packets of different network segments.

The topology of the experiment is as follows:

650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P034FH-0.png "width =" 644 "height =" 255 "/>

The IP configuration of the router is as follows:

650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P034M20-1.png "width =" 644 "height =" 351 "/>

Echo 1>/proc/sys/net/ipv4/ip_forward enable Nic forwarding

Configure DNS

Install DNS

Yum-y install bind -*

Echo "">/etc/resolv. conf DNS pointing to null

Vim/var/named/chroot/etc/named. conf create a configuration file

Options {
Directory "/var/named ";
};
Zone "sina.com "{
Type master;
File "sina.com. zone ";

};
Zone "yahoo.com "{
Type master;
File "yahoo.com. zone ";
};

Cp/usr/share/doc/bind-9.3.6/sample/var/named/localhost. zone/var/named/chroot/var/named/yahoo.com. zone

Cp/usr/share/doc/bind-9.3.6/sample/var/named/localhost. zone/var/named/chroot/var/named/sina.com. zone copy template file to region File

Cd/var/named/chroot/var/named/

Vim yahoo.com. zone

650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0343040-2.png "width =" 644 "height =" 236 "/>

Vim sina.com. zone

650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0345437-3.png "width =" 644 "height =" 213 "/>

Restart service named restart

Test

650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P034K35-4.png "width =" 644 "height =" 272 "/>

OK resolution successful

Configuration on sina Machine

1. Set the parsing File

Vi/etc/resolv. conf

Nameserver 192.168.1.1

Host mail.sina.com resolution host address

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0345057-5.png "" 644 "height =" 146 "/>

If the resolution fails, we recommend that you add a route record.

Route add-net 192.168.2.0/24 gw 192.168.1.1 Destination Address Gateway

2. Disable the sendmial service.

Service sendmail stop

Chkconfig sendmail off

3. Install postfix to send emails

Yum-y install postfix

Vim/etc/postfix/main. cf

Myhostname = mail.sina.com
Mydomain = sina.com
Myorigin = $ mydomain
Inet_interfaces = all
Mydestination = $ myhostname, $ mydomain
Mynetworks = 192.168.1.0/24,192.168 .2.0, 127.0.0.0/8
Relay domains = sina.com, yahoo.com set which domains can be forwarded for mail
Add at the end of the configuration file

Smtpd_sasl_auth_enable = yes
Smtpd_sasl_local_domain =''
Smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
Broken_sasl_auth_clients = yes
Smtpd_client_restrictions = permit_sasl_authenticated
Smtpd_sasl_security_options = noanonymous

Save and exit

Vim/etc/sysconfig/saslauthd modify the configuration file of the saslauthd service
Modify MECH = shadow

Exit
Create a user sina and set a password for the user

Useradd sina

Passwd sina
Start saslauthd service
/Etc/init. d/saslauthd restart
Chkconfig saslauthd on
Test command
Testsaslauthd-u sina-p 'abc-1000'

If OK Success is returned, the saslauthd service is successfully working.

Service postfix restart postfix service

Test postfix

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0344395-6.png "" 644 "height =" 234 "/>

If the code 250 is returned, the postfix is successfully configured.

4. Install the dovecot service to receive emails

Yum-y install dovecot
Modify configuration file
Vi/etc/dovecot. conf

There are two places to modify

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0343647-7.png "" 644 "height =" 337 "/>

Set the protocols pop3 and pop3s in row 20th.

Remove the comment in row 35th to listen to the POP3 port. Note that the top-level write includes 38 rows.} It is also a fixed-line write. Otherwise, the linux system will read spaces before reading other configurations.

Service dovecot restart service

Chkconfig dovecot on

Modify the postfix primary configuration file

Found at about 456 rows

Mailbox_transport = lmtp: unix:/var/lib/imap/socket/lmtp remove this line of comment to associate it

Yum-y install cyrus-imapd-devel

Cat/etc/passwd file

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P034B50-8.png "" 644 "height =" 82 "/>

We can see that there is a cyrus user.

Set cyrus Password

Passwd cyrus

Restart service
/Etc/init. d/cyrus-imapd restart
Chkconfig cyrus-imapd on

Link to the background
Cyradm-u cyrus localhost

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0344634-9.png "" 644 "height =" 150 "/>

Create an sina email user

Then exit quit.

5. Install webmail

Yum-y install squirrelmail

Run the PHP setup Tool
/Usr/share/squirrelmail/config/conf. pl

1) Input 2 server settings in command

Enter the digit 1 in sequence to modify the configuration.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P034CX-10.png "" 644 "height =" 290 "/>

R returns and then input the A-------8 to change to Cyrus

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0345910-11.png "" 542 "height =" 484 "/>

R return and enter 4 General Options and then select 5 to change the value to true # ignore uppercase/lowercase letters

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P03460P-12.png "" 524 "height =" 484 "/>

R returns and enters D Set pre-defined settings for specific IMAP server.

IMAP Server: cyrus

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0344241-13.png "" 503 "height =" 374 "/>

S. Save q and start httpd service httpd restart.

If not, install httpd service yum-y install http -*

Open browser input http://mail.sina.com/webmail/

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0342493-14.png "" 644 "height =" 368 "/>

After Login

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P03464D-15.png "" 644 "height =" 343 "/>

Send an email to test

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P034K37-16.png "" 644 "height =" 354 "/>

OK test successful

Then configure yahoo.

1. Set the parsing File

Vi/etc/resolv. conf

Nameserver 192.168.2.1

Starting from step 2, the only difference with sina machine configuration is that the mailbox user name is set up. Here we configure a yahoo mailbox user on the yahoo machine.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0345202-17.png "" 644 "height =" 389 "/>

After logging on, send an email to the sina user.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0341F2-18.png "" 644 "height =" 440 "/>

Then, check whether sina has received the email.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0344007-19.png "" 642 "height =" 484 "/>

Sina, give yahoo another try.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P03410I-20.png "" 644 "height =" 434 "/>

View emails at yahoo

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/1P0341436-21.png "" 644 "height =" 448 "/>

I have received a reply to the experiment. OK. Here is a drawback. Every time I create a new mailbox user, I will create a new user name on the server. Next time I want to improve the virtual user, please kindly advise.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.