歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux server mail配置

linux server mail配置

日期:2017/3/1 16:15:18   编辑:關於Linux
linux server mail配置 postfix(MTA smtp)+dovecot(pop3/imap)+squirrelmail(webmail)+apache+php+bind 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:[email protected] 250 2.1.0 Ok rcpt to:[email protected] 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. <[email protected]> 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:[email protected] 250 2.1.0 Ok rcpt to:[email protected] 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. <[email protected]> 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. <[email protected]> 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: <[email protected]> X-Original-To: [email protected] Delivered-To: [email protected] Received: from localhost (s17 [192.168.0.17]) by mail.baidu.com (Postfix) with ESMTP id B2AEA2E0002 for <[email protected]>; 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 [email protected] 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 [email protected]:/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/
Copyright © Linux教程網 All Rights Reserved