热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linux系统本地sendmail邮件服务器配置

1.安装dns1.1安装包[root@mail~]#yuminstallbind[root@mail~]#yuminstallbind-chroot?改变dns的路径,保证安全的包[root@mail~]#yuminstallcaching-nameserver?y?生成配置文件,提高cachingserver[roo

 

1.安装dns

1.1 安装包

[root@mail ~]# yum install bind 

[root@mail ~]# yum install bind-chroot ?改变dns的路径,保证安全的包

[root@mail ~]# yum install caching-nameserver ?y ?生成配置文件,提高caching server

[root@mail ~]# yum list all |grep bind

This system is not registered with RHN.

RHN support will be disabled.

bind.i386            30:9.3.4-10.P1.el5    installed          

bind-chroot.i386                       30:9.3.4-10.P1.el5    installed          

bind-libs.i386         30:9.3.4-10.P1.el5    installed          

bind-utils.i386          30:9.3.4-10.P1.el5    installed          

ypbind.i386            3:1.19-11.el5         installed      

 

1.2 配置

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

[root@mail etc]# cp -p named.caching-nameserver.conf named.conf

[root@mail etc]# vim named.conf

options {

        listen-on port 53 { any; };

        allow-query     { any; };

};

view localhost_resolver {

        match-clients      { any; };

        match-destinations { any; };

        include "/etc/named.rfc1912.zones";

};

1.3声明区域

 

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

zone "bj.com" IN {

        type master;

        file "bj.com.db";

        allow-update { none; };

};

 

1.4产生数据库文件

[root@mail named]# cp -p localhost.zone bj.com.db

[root@mail named]# vim bj.com.db 

$TTL    86400

@               IN SOA  ns.bj.com.       root.126.com (

                      42              ; serial (d. adams)

                      3H              ; refresh

                      15M             ; retry

                      1W              ; expiry

                      1D )            ; minimum

 

                IN NS           ns.bj.com.

ns              IN A            192.168.101.70

mail            IN A            192.168.101.70

pop3            IN CNAME        mail

smtp            IN CNAME        mail

imap            IN CNAME        mail

@               IN MX      10   mail

1.5 dns指向

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

#search localdomain

nameserver 192.168.101.70

[root@mail named]# vim /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=mail.bj.com

[root@mail etc]# vim /etc/hosts

127.0.0.1               localhost.localdomain localhost

192.168.101.70  mail.bj.com

--更改主机名

1.6 开启服务 解析

[root@mail named]# 

[root@mail named]# service named start

Starting named:                          [  OK  ]

[root@mail named]# chkconfig named on

[root@mail named]# rndc reload

server reload successful

[root@mail etc]# nslookup mail.bj.com

Server:     192.168.101.70

Address:    192.168.101.70#53

 

Name:   mail.bj.com

Address: 192.168.101.70

 

[root@mail etc]# dig    -t mx bj.com

 

; <<>> DiG 9.3.4-P1 <<>> -t mx bj.com

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24728

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

 

;; QUESTION SECTION:

;bj.com.                        IN      MX

 

;; ANSWER SECTION:

bj.com.         86400   IN      MX      10 mail.bj.com.

 

;; AUTHORITY SECTION:

bj.com.         86400   IN      NS      ns.bj.com.

 

;; ADDITIONAL SECTION:

mail.bj.com.            86400   IN      A       192.168.101.70

ns.bj.com.      86400   IN      A       192.168.101.70

 

;; Query time: 1 msec

;; SERVER: 192.168.101.70#53(192.168.101.70)

;; WHEN: Sun Sep  4 16:59:01 2011

;; MSG SIZE  rcvd: 94

[root@mail etc]#

 

 

2.Sendmail 需要的包

2.1需要安装的包

Sendmail-8.13.8。-2.el5 ?主包

Sendmai-cf          --生成易配置或快速配置的配置文件

Sendmail-devel   --开发包

m4.i386              1.4.5-3.el5.1               --转换工具

--重启m4会自动转换

--sendmail.mc—>sendmail.cf

-- accessaccess.db

[root@mail ~]# yum list all |grep sendmail

This system is not registered with RHN.

RHN support will be disabled.

sendmail.i386                          8.13.8-2.el5          installed          

sendmail-cf.i386                       8.13.8-2.el5          installed          

sendmail-devel.i386                    8.13.8-2.el5          installed          

sendmail-doc.i386                      8.13.8-2.el5          installed   

[root@mail ~]# yum list all |grep m4      

This system is not registered with RHN.

RHN support will be disabled.

m4.i386              1.4.5-3.el5.1         installed          

[root@mail ~]#

 

 

 

2.2配置监听

更改sendmail.mc

[root@mail mail]# pwd

/etc/mail

[root@mail mail]# vim sendmail.mc

116 DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

--默认是本机监听25号端口,需要更改才能使非本地用户使用sendmail发送邮件

--Dnl # 是注视文字

--Dnl 是打开可以使用的

--末尾dnl 去除空格

[root@mail mail]# service sendmail restart

[root@mail mail]# netstat -tunpl |grep 25

tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      30569/sendmail: acc

--添加本地用户

[root@mail etc]# useradd user1

[root@mail etc]# useradd user2

[root@mail etc]# passwd user1

[root@mail etc]# passwd user2

--可以通过日志文件查看错误

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

# Log all the mail messages in one place.

mail.*              -/var/log/maillog

 

2.3本地发送接收邮件

[root@mail mail]# mail user1

Subject: uu

ws

.

Cc: 

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

[root@mail mail]# ll /var/spool/mail/

total 24

-rw-rw---- 1 redhat mail    0 Aug 27 14:35 redhat

-rw------- 1 root   root 7153 Sep  4 17:30 root

-rw-rw---- 1 rpc    mail    0 Aug 27 22:21 rpc

-rw------- 1 user1  mail 1693 Sep  4 17:30 user1

-rw-rw---- 1 user2  mail  575 Sep  4 17:30 user2

[user1@mail ~]$ mail

Mail version 8.1 6/6/93.  Type ? for help.

"/var/spool/mail/user1": 3 messages 3 new

>N  1 root@mail.bj.com      Sun Sep  4 17:30  17/565   "e"

 N  2 root@mail.bj.com      Sun Sep  4 17:30  16/565   "u"

 N  3 root@mail.bj.com      Sun Sep  4 17:30  16/563   "1"

& 1

Message 1:

From root@mail.bj.com  Sun Sep  4 17:30:56 2011

Date: Sun, 4 Sep 2011 17:18:47 +0800

From: root

To: user1@mail.bj.com

Subject: e

 

e

 .

 

& 2

 

 

[root@mail mail]# tail /var/log/maillog

Sep  4 17:30:56 localhost sendmail[30570]: p849UuLM030570: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31521, dsn=2.0.0, stat=Sent

Sep  4 17:30:56 localhost sendmail[30570]: p849BPv9030362: to=, ctladdr= (0/0), delay=00:19:31, xdelay=00:00:00, mailer=local, pri=300303, dsn=2.0.0, stat=Sent

--如果sendmail.mc 116 DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA,M=Ea')dnl

--会报错发送不出去mail

Sep  4 17:31:08 localhost sendmail[30587]: p849V8Ni030587: from=root, size=26, class=0, nrcpts=1, msgid=<201109040931.p849V8Ni030587@mail.bj.com>, relay=root@localhost

Sep  4 17:31:08 localhost sendmail[30587]: p849V8Ni030587: to=user1, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30026, relay=[127.0.0.1] [127.0.0.1], dsn=5.0.0, stat=Service unavailable

 

3.安装MAA

需要安装dovecot开启pop3才可以发送接收邮件

否则出错

 

3.1安装dovecot

[root@mail ~]# yum install dovecot

 

 

--Package dovecot-1.0.7-7.el5.i386 already installed and latest version

 

3.2 更改配置文件

[root@mail ~]# rpm -qc dovecot

/etc/dovecot.conf

 

 

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

  20 #protocols = imap imaps pop3 pop3s

 --默认全开

  22 protocols = pop3 

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

tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      4659/sendmail: acce 

udp        0      0 :::43725                    :::*                  3191/avahi-daemon:  

[root@mail ~]# netstat -tupln |grep dov

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

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

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

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

[root@mail ~]# grep 993 /etc/services

imaps           993/tcp       # IMAP over SSL

imaps           993/udp       # IMAP over SSL

imap4-ssl       585/tcp       # IMAP4+SSL (use 993 instead)

imap4-ssl       585/udp       # IMAP4+SSL (use 993 instead)

 

 

[root@mail ~]# grep 995 /etc/services

pop3s           995/tcp       # POP-3 over SSL

pop3s           995/udp       # POP-3 over SSL

 

 

[root@mail ~]# service dovecot restart

 

 

 

 

[root@mail ~]# chkconfig dovecot on

3.3客户端使用sendmail发送接收mail

1. 配置outlook

 

[root@mail ~]# mail user1 

Subject: hhh

gfgfg

.

Cc: 

 

27-4

3.4使用Outlook发信

 

 


 

 

3.5telnet发送邮件

[root@mail ~]# telnet mail.bj.com 25

-----中间输入出错可以使用shift+esc+backspace退格。 

Trying 192.168.101.70...

Connected to mail.bj.com (192.168.101.70).

Escape character is '^]'.

220 mail.bj.com ESMTP Sendmail 8.13.8/8.13.8; Thu, 15 Sep 2011 16:54:23 +0800

help

214-2.0.0 This is sendmail

214-2.0.0 Topics:

214-2.0.0       HELO    EHLO    MAIL    RCPT    DATA

214-2.0.0       RSET    NOOP    QUIT    HELP    VRFY

214-2.0.0       EXPN    VERB    ETRN    DSN     AUTH

214-2.0.0       STARTTLS

214-2.0.0 For more info use "HELP ".

214-2.0.0 To report bugs in the implementation see

214-2.0.0       http://www.sendmail.org/email-addresses.html

214-2.0.0 For local information send email to Postmaster at your site.

214 2.0.0 End of HELP info

helo mail.bj.com

250 mail.bj.com Hello mail.bj.com [192.168.101.70], pleased to meet you

mail from: user1@mail.bj.com

250 2.1.0 user1@mail.bj.com... Sender ok

rcpt to :user2@mail.bj.com          

250 2.1.5 user2@mail.bj.com... Recipient ok

data

354 Enter mail, end with "." on a line by itself

subject

hello user2.this is user1.

.

250 2.0.0 p8F8sNcf032532 Message accepted for delivery

quit  

221 2.0.0 mail.bj.com closing connection

Connection closed by foreign host.

[root@mail ~]#

 


推荐阅读
  • SQL Server 2008 到底需要使用哪些端口?
    SQLServer2008到底需要使用哪些端口?-下面就来介绍下SQLServer2008中使用的端口有哪些:  首先,最常用最常见的就是1433端口。这个是数据库引擎的端口,如果 ... [详细]
  • Linux防火墙配置—允许转发
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • Ansem 最新雄文:软着陆后,加密市场下阶段趋势与核心叙事
    市场最糟糕的时候已经过去,以太坊合并前不太会看到新的低点;但仍需来自关注宏观市场的不确定风险。撰文:Ansem ... [详细]
  • 禁止程序接收鼠标事件的工具_VNC Viewer for Mac(远程桌面工具)免费版
    VNCViewerforMac是一款运行在Mac平台上的远程桌面工具,vncviewermac版可以帮助您使用Mac的键盘和鼠标来控制远程计算机,操作简 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • CentOS 7部署KVM虚拟化环境之一架构介绍
    本文介绍了CentOS 7部署KVM虚拟化环境的架构,详细解释了虚拟化技术的概念和原理,包括全虚拟化和半虚拟化。同时介绍了虚拟机的概念和虚拟化软件的作用。 ... [详细]
  • mac php错误日志配置方法及错误级别修改
    本文介绍了在mac环境下配置php错误日志的方法,包括修改php.ini文件和httpd.conf文件的操作步骤。同时还介绍了如何修改错误级别,以及相应的错误级别参考链接。 ... [详细]
  • 本文介绍了5个基本Linux命令行工具的现代化替代品,包括du、top和ncdu。这些替代品在功能上进行了改进,提高了可用性,并且适用于现代化系统。其中,ncdu是du的替代品,它提供了与du类似的结果,但在一个基于curses的交互式界面中,重点关注占用磁盘空间较多的目录。 ... [详细]
  • 本文分享了一位Android开发者多年来对于Android开发所需掌握的技能的笔记,包括架构师基础、高级UI开源框架、Android Framework开发、性能优化、音视频精编源码解析、Flutter学习进阶、微信小程序开发以及百大框架源码解读等方面的知识。文章强调了技术栈和布局的重要性,鼓励开发者做好学习规划和技术布局,以提升自己的竞争力和市场价值。 ... [详细]
  • 介绍一款好用的内网穿透工具FRP
    本文介绍了一款好用的内网穿透工具FRP,它是一个使用Go语言开发的高性能的反向代理应用。FRP支持多种协议类型,并且可以根据域名进行路由转发。 ... [详细]
  • 概述H.323是由ITU制定的通信控制协议,用于在分组交换网中提供多媒体业务。呼叫控制是其中的重要组成部分,它可用来建立点到点的媒体会话和多点间媒体会议 ... [详细]
  • 篇首语:本文由编程笔记#小编为大家整理,主要介绍了VoLTE端到端业务详解|VoLTE用户注册流程相关的知识,希望对你有一定的参考价值。书籍来源:艾怀丽 ... [详细]
  • UDP千兆以太网FPGA_verilog实现(四、代码前期准备UDP和IP协议构建)
    UDP:userDatagramprotocol用户数据报协议无连接的传输层协议,提供面向事务的简单不可靠信息传送服务,IETFRFC76 ... [详细]
  • IP、ARP、TCP、UDP、ICMP、DNS、路由协议、DHCP协议的缺陷,容易受到的攻击,以及防御措施1、IP协议1.1、介绍: ... [详细]
author-avatar
手机用户2602939233
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有