您的位置:首页 > 运维架构 > Linux

centos6 postfix配置

2016-02-02 21:54 417 查看
1.设置主机名

[root@www ~]# vim /etc/sysconfig/network

[root@www ~]# hostname mail.baidu.com

[root@www ~]# vim /etc/hosts

192.168.0.1 www.baidu.com www baidu.com

2.配置DNS

[root@www ~]# yum -y remove bind

[root@www ~]# yum -y install bind

[root@mail ~]# vim /etc/named.conf

listen-on port 53 { 127.0.0.1; any; };

allow-query { localhost; any; };

[root@mail ~]# vim /etc/named.rfc1912.zones

zone "baidu.com" IN {

type master;

file "baidu.com.zone";

allow-update { none; };

};

[root@mail ~]# named-checkconf /etc/named.conf

[root@mail ~]# cd /var/named/

[root@mail named]# cp named.localhost baidu.com.zone -a

[root@mail named]# vim baidu.com.zone

$TTL 1D

@ IN SOA dns1.baidu.com. root.baidu.com. (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

@ NS dns1.baidu.com.

dns1 A 192.168.0.1

www A 192.168.0.100

@ MX 5 mail.baidu.com.

mail A 192.168.0.1

pop A 192.168.0.1

imap A 192.168.0.1

[root@mail named]# named-checkzone baidu.com /var/named/baidu.com.zone

zone baidu.com/IN: loaded serial 0

OK

[root@mail named]# service named start

Starting named: [ OK ]

[root@mail named]# chkconfig named on

[root@mail named]# nslookup

> server

Default server: 192.168.0.17

Address: 192.168.0.17#53

> exit

[root@mail named]# vim /etc/resolv.conf

nameserver 192.168.0.1

[root@mail named]# nslookup

> server

Default server: 192.168.0.1

Address: 192.168.0.1#53

> set type=ns

> baidu.com

Server: 192.168.0.1

Address: 192.168.0.1#53

baidu.com nameserver = dns1.baidu.com.

> set type=mx

> baidu.com

Server: 192.168.0.1

Address: 192.168.0.1#53

baidu.com mail exchanger = 5 mail.baidu.com.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

3.配置postfix

[root@mail ~]# rpm -qa | grep postfix

postfix-2.6.6-2.el6.x86_64

75 myhostname = mail.baidu.com

83 mydomain = baidu.com

99 myorigin = $mydomain

116 inet_interfaces = all

119 inet_protocols = ipv4

164 mydestination = $myhostname, $mydomain, localhost

264 mynetworks = 192.168.0.0/24

419 home_mailbox = Maildir/

[root@mail ~]# service postfix restart

Shutting down postfix: [FAILED]

Starting postfix: [FAILED]

[root@mail ~]# postfix stop

postfix/postfix-script: stopping the Postfix mail system

[root@mail ~]# postfix start

postfix/postfix-script: starting the Postfix mail system

[root@mail ~]# netstat -tnlp |grep :25

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 8731/master

4.使用dovecot实现110/143收信

# yum -y install dovecot

[root@mail ~]# /etc/init.d/dovecot start

正在启动 Dovecot Imap: [确定]

[root@mail ~]# chkconfig dovecot on

tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 8789/dovecot

tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 8789/dovecot

tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 8789/dovecot

tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 8789/dovecot

tcp 0 0 :::110 :::* LISTEN 8789/dovecot

tcp 0 0 :::143 :::* LISTEN 8789/dovecot

tcp 0 0 :::993 :::* LISTEN 8789/dovecot

tcp 0 0 :::995 :::* LISTEN 8789/dovecot

测试:是否能够收发邮件

发信件

[root@mail ~]# telnet localhost 25

Trying ::1...

telnet: connect to address ::1: Connection refused

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

220 mail.baidu.com ESMTP Postfix

ehlo localhost

250-mail.baidu.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:root@baidu.com

250 2.1.0 Ok

rcpt to:a@baidu.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

subject:a test mail

hi a.

.

250 2.0.0 Ok: queued as 12C1B2E0002

quit

221 2.0.0 Bye

Connection closed by foreign host.

收邮件

[root@mail ~]# telnet localhost 110

Trying ::1...

Connected to localhost.

Escape character is '^]'.

+OK Dovecot ready. <2310.1.50eb9602.Wwof2gVP8FFYVTmyZ5vj7A==@mail.baidu.com>

user a

+OK

pass 1

+OK Logged in.

list

+OK 1 messages:

1 436

.

retr 1

如果用其它PC登录可不可以收发邮件

ssh 192.168.0.17

[root@desktop17 ~]# yum -y install telnet

[root@dns1 ~]# telnet 192.168.0.1

Trying 192.168.0.1...

telnet: connect to address 192.168.0.1: Connection refused

[root@dns1 ~]# telnet 192.168.0.1 25

Trying 192.168.0.1...

Connected to 192.168.0.1.

Escape character is '^]'.

220 mail.baidu.com ESMTP Postfix

ehlo localhost

250-mail.baidu.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:test2@baidu.com

250 2.1.0 Ok

rcpt to:a@baidu.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

subject:a test mail telnet

hi a.

.

250 2.0.0 Ok: queued as B2AEA2E0002

quit

221 2.0.0 Bye

Connection closed by foreign host.

[root@dns1 ~]# telnet 192.168.0.1 110

Trying 192.168.0.1...

Connected to 192.168.0.1.

Escape character is '^]'.

+OK Dovecot ready. <2365.1.50eb9703.T8b8hHgcZ5ZFExiwEfiz8w==@mail.baidu.com>

user a

-ERR Plaintext authentication disallowed on non-secure (SSL/TLS) connections.

不允许pop3明文登录

[root@mail ~]# vim /etc/dovecot/conf.d/10-auth.conf

9 disable_plaintext_auth = no

[root@www ~]# service dovecot reload

[root@dns1 ~]# telnet 192.168.0.1 110

Trying 192.168.0.1...

Connected to 192.168.0.1.

Escape character is '^]'.

+OK Dovecot ready. <2437.1.50eb9825.5Ls9iuJ+nWBnJ9+cIwCTLA==@mail.baidu.com>

user a

+OK

pass 1

+OK Logged in.

list

+OK 2 messages:

1 436

2 286

.

retr

-ERR There's no message 0.

retr

-ERR There's no message 0.

retr 2

+OK 286 octets

Return-Path: <test2@baidu.com>

X-Original-To: a@baidu.com

Delivered-To: a@baidu.com

Received: from localhost (s17 [192.168.0.17])

by mail.baidu.com (Postfix) with ESMTP id B2AEA2E0002

for <a@baidu.com>; Tue, 8 Jan 2013 11:47:48 +0800 (CST)

subject:a test mail telnet

hi a.

.

5.配置WEB客服端

#yum -y remove httpd

# yum -y install httpd php

# vim /etc/httpd/conf/httpd.conf

ServerName mail.baidu.com

# service httpd start

# chkconfig httpd on

创建httpd虚拟主机

# vim /etc/httpd/conf/httpd.conf

<Directory /mail>

Options Indexes

AllowOverride None

Order allow,deny

Allow from 192.168.0.0/24

</Directory>

NameVirtualHost *:80

<VirtualHost *:80>

ServerAdmin root@baidu.com

DocumentRoot /mail

ServerName mail.baidu.com

ErrorLog logs/mail.baidu.com-error_log

CustomLog logs/mail.baidu.com.example.com-access_log common

</VirtualHost>

# mkdir /mail

# yum -y install php

# service httpd start

# chkconfig httpd on

-------------------------------

创建web,支持通过网页收发邮件

# scp zh_CN-1.4.13-20071220.tar.bz2 squirrelmail-1.4.13.tar.bz2 root@192.168.0.16:/root

# tar xf squirrelmail-1.4.13.tar.bz2

# mv /root/squirrelmail-1.4.13/* /mail/

打中文补丁包

# mkdir /root/zh

# tar xf zh_CN-1.4.13-20071220.tar.bz2 -C /root/zh

cd /root/zh

# ./install

Please enter path to your squirrelmail installation:/mail

创建配置文件 :

# cd /mail/config

# cp config_default.php config.php

# vim /mail/config/config.php

118 $domain = 'baidu.com';

1000 $squirrelmail_default_language = 'zh_CN';

1015 $default_charset = 'zh_CN.UTF-8';

487 $data_dir = '/mail/data/';

--邮件数据

505 $attachment_dir = '/mail/attach/'; --邮件附件

# mkdir /mail/{data,attach} -p

# chown -R apache.apache /mail/data/ /mail/attach/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: