Linux网络服务_邮件服务器-Redhat Enterprise 5.9

简介:

Linux网络服务_邮件服务器-Redhat Enterprise 5.9


案例环境:

邮件服务器:mail.tarena.com192.168.1.100

邮件域:@tarena.com

邮件账号:服务器的系统用户

发信服务软件:postfix

授信服务软件:dovecot


第一部分:安装并测试发信服务软件postfix

第一步:与邮件相关的DNS设置

需要事先配置dns,在正向文件中添加相应的MX记录、A记录

[root@server1 ~]# cat /var/named/chroot/var/named/tarena.com.zheng

$TTL    86400

@       IN      SOA    tarena.com. root.tarena.com.  (

                                     2014031001 ; Serial

                                     28800      ; Refresh

                                     14400      ; Retry

                                     3600000    ; Expire

                                     86400)     ; Minimum

       IN      NS       server1.tarena.com.

      IN     MX  5   mail.tarena.com.

server1 IN      A        192.168.1.100

mail    IN    A       192.168.1.100

[root@server1 ~]#


第二步:安装postfix服务

注:

1,在安装postfix服务之前,需要先关闭sendmail服务,避免端口冲突

2,依赖包为perl-DBI,安装完后要添加postfix服务

3,需要手动添加postfix服务:chkconfig --add postfix


[root@server1 ~]# service sendmail stop

关闭 sm-client:                                           [确定]

关闭 sendmail:                                            [确定]

[root@server1 ~]# chkconfig sendmail off

[root@server1 ~]# yum -y install postfix

[root@server1 ~]# chkconfig --add postfix

[root@server1 ~]# chkconfig --list postfix

postfix         0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

[root@server1 ~]# service postfix start

启动 postfix:                                             [确定]

[root@server1 ~]#


第三步:修改主配置文件:/etc/postfix/main.cf

注:

服务配置:/etc/postfix/main.cf

主程序配置:/etc/postfix/master.cf

postconf辅助工具:

无选项时,查看当前的有效配置

选项-n,查看非默认配置

选项-d,查看默认的配置

利用postconf提取有效配置,排除干扰项、只保留非默认的配置

注:由于postconf-n在输出信息的过程中,需要读取main.cf文件,所以,先执行

post -n >test.txt,之后再将main.cf更名为main.cf.old,否则,非默认的配置内容将会改变,最后再在将text.txt改名为main.cf,那么main.cf里面的内容就为非默认的配置了。

[root@server1 ~]# cd /etc/postfix/

[root@server1 postfix]# postconf -n > test.txt

[root@server1 postfix]# mv main.cf main.cf.old

[root@server1 postfix]# mv test.txt main.cf

[root@server1 postfix]# vim main.cf

[root@server1 postfix]# cat main.cf

alias_database = hash:/etc/aliases

alias_maps = hash:/etc/aliases

command_directory = /usr/sbin

config_directory = /etc/postfix

daemon_directory = /usr/libexec/postfix

debug_peer_level = 2

html_directory = no

#inet_interfaces = localhost       //把这一行注释掉,否则只允许本地回环地址

mail_owner = postfix

mailq_path = /usr/bin/mailq.postfix

manpage_directory = /usr/share/man

mydestination = $myhostname, localhost.$mydomain,localhost

newaliases_path = /usr/bin/newaliases.postfix

queue_directory = /var/spool/postfix

readme_directory =/usr/share/doc/postfix-2.3.3/README_FILES

sample_directory =/usr/share/doc/postfix-2.3.3/samples

sendmail_path = /usr/sbin/sendmail.postfix

setgid_group = postdrop

unknown_local_recipient_reject_code = 550

myhostname = mail.tarena.com       //邮件服务器名子

mydomain = tarena.com       //邮件域

myorigin = $mydomain     //显示发件域,随邮件域变化

mydestination = $mydomain,$myhostname     //本地投递域

home_mailbox = Maildir/         //邮箱类型,这里指定在家目录的Maildir下

[root@server1 postfix]# service postfix restart

关闭 postfix:                                             [确定]

启动 postfix:                                             [确定]

[root@server1 postfix]# netstat -anpt | grep 25

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

[root@server1 postfix]#


第四步:测试SMTP发信

使用telnet工具:连接到25端口,执行发信指令

基本的SMTP指令

   HELO:宣告客户机地址(大小写均可)

   MAIL FROM:指定发件人邮箱地址

   RCPT TO:指定收件人邮箱地址

   DATA:编写邮件内容,SUBJECT为主题,结束则需另起一行,一点“.”结束

[root@server1 ~]#telnet mail.tarena.com 25

Trying192.168.1.100...

Connected tomail.tarena.com (192.168.1.100).

Escape character is'^]'.

220 mail.tarena.comESMTP Postfix

helo mail.tarena.com            //给mail.tarena.com打招呼

250 mail.tarena.com             //mail.tarena.com给出250回应,如果是501则失败

mail from:nick@tarena.com       //发信人为nick

250 2.1.0 Ok

rcpt to:hunter@tarena.com       //收信任为hunter

250 2.1.5 Ok

data        //正文的开始

354 End data with<CR><LF>.<CR><LF>     //提示以“.”结束

subject:Test mail           //邮件标题,subject开头

this is a test mail...         //这是邮件内容

.           //以“.”结束

250 2.0.0 Ok: queuedas A68ED41BFB3

quit        //quit退出邮件系统

221 2.0.0 Bye

Connection closed byforeign host.

[root@server1 ~]# ls /home/hunter/Maildir/new/      //查看新邮件列表

1394448613.V803I30cf17M502725.server1.tarena.com

[root@server1 ~]# cd /home/hunter/Maildir/new/      //邮件存放位置

[root@server1 new]# cat 1394448613.V803I30cf17M502725.server1.tarena.com

Return-Path:<nick@tarena.com>

X-Original-To:hunter@tarena.com

Delivered-To:hunter@tarena.com

Received:from mail.tarena.com (server1.tarena.com [192.168.1.100])

       by mail.tarena.com (Postfix) with SMTPid A68ED41BFB3

       for <hunter@tarena.com>; Mon, 10Mar 2014 18:49:16 +0800 (CST)

subject:Testmail

Message-Id:<20140310104939.A68ED41BFB3@mail.tarena.com>

Date:Mon, 10 Mar 2014 18:49:16 +0800 (CST)

From:nick@tarena.com

To:undisclosed-recipients:;


thisis a test mail ...

[root@server1 new]#


第二部分:安装并测试收信服务软件dovecot


第一步:安装dovecot软件并启动该服务

[root@server1 ~]#yum install dovecot

[root@server1 ~]#chkconfig --list dovecot

dovecot         0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭

[root@server1 ~]#service dovecot start

启动 DovecotImap:                                        [确定]

[root@server1 ~]#chkconfig dovecot on

[root@server1 ~]#


第二步:配置收信服务

调整dovecot配置:

1,整个配置文件基本不需更改,只需保证以下三个字段正确即可:

/etc/dovecot.conf配置文件中

ssl_disable = yes                   //禁用ssl加密

disable_plaintest_auth= no         //允许明文认证通信

mail_location =maildir:~/Maildir   //设置邮箱路径

2,重新启动服务:service dovecot restart

3,保证tcp的110和143端口开启

[root@server1 ~]# netstat -anpt | grep dovecot

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

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

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

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

[root@server1 ~]#



第三步:测试POP3/IMAP收信

使用telnet工具:连接到110或143端口,执行收信指令

基本的SMTP指令:

   USER:指定登录账号

   PASS:指定用于验证的密码

   LIST:查看邮件列表

   RETR:获取指定编号的邮件内容


[root@server1 ~]# telnet mail.tarena.com 110

Trying192.168.1.100...

Connected tomail.tarena.com (192.168.1.100).

Escape character is'^]'.

+OK Dovecot ready.

user hunter

+OK

pass 123

+OK Logged in.

list

+OK 2 messages:

1 473

.

retr 1

+OK 491 octets

Return-Path:<nick@tarena.com>

X-Original-To:hunter@tarena.com

Delivered-To:hunter@tarena.com

Received: frommail.tarena.com (server1.tarena.com [192.168.1.100])

       by mail.tarena.com (Postfix) with SMTPid A68ED41BFB3

       for <hunter@tarena.com>; Mon, 10Mar 2014 18:49:16 +0800 (CST)

subject:Test mail

Message-Id:<20140310104939.A68ED41BFB3@mail.tarena.com>

Date: Mon, 10 Mar2014 18:49:16 +0800 (CST)

From:nick@tarena.com

To:undisclosed-recipients:;


this is a test mail...

.

quit

+OK Logging out.

Connection closed byforeign host.

[root@server1 ~]#


需要注意的几点:

1,在安装postfix之前,需要先停了sendmail服务,同样的邮件软件,占用的端口都是25,如果不停用,可能会导致无法启动postfix;

2,postfix是发送邮件的服务,dovecot是接收邮件的服务,两个软件合起来才能完成发送和接受的服务,所以需要完成两个部分的安装和配置;

3,在做测试的过程中,可以通过一个windows的客户端,安装foxmail软件,在foxmail中建立账户,互发和接受信件,进行测试!


扩展:邮件服务器的安全

1:SMTP认证控制:http://murongqingqqq.blog.51cto.com/2902694/1372074

2:搭建Webmail系统:http://murongqingqqq.blog.51cto.com/2902694/1372074



本文转自 murongqingqqq  51CTO博客,原文链接:http://blog.51cto.com/murongqingqqq/1372049

相关文章
|
12天前
|
存储 安全 Linux
Dell OpenManage Enterprise 4.4 - Dell 服务器、存储和网络设备集中管理软件
Dell OpenManage Enterprise 4.4 - Dell 服务器、存储和网络设备集中管理软件
36 4
Dell OpenManage Enterprise 4.4 - Dell 服务器、存储和网络设备集中管理软件
|
2天前
|
Linux 数据安全/隐私保护
使用Linux命令行接入无线网络Wi-Fi的示例。
现在,你已经使用命令行成功地连接到 Wi-Fi 网络了。这两个示例涵盖了用 `nmcli` 和 `wpa_supplicant` 连接无线网络的常见场景,让你能够不依赖图形化界面来完成这个任务。在日常使用中熟练掌握这些基本操作能增强你对 Linux 系统的理解,帮助你更有效地处理各种问题。
24 12
|
13天前
|
Ubuntu Linux 网络安全
在Linux云服务器上限制特定IP进行SSH远程连接的设置
温馨提示,修改iptables规则时要格外小心,否则可能导致无法远程访问你的服务器。最好在掌握足够技术知识和理解清楚操作含义之后再进行。另外,在已经配置了防火墙的情况下,例如ufw(Ubuntu Firewall)或firewalld,需要按照相应的防火墙的规则来设置。
65 24
|
1天前
|
数据挖掘 Linux 数据库
服务器数据恢复—Linux系统服务器数据恢复案例
服务器数据恢复环境: linux操作系统服务器中有一组由4块SAS接口硬盘组建的raid5阵列。 服务器故障: 服务器工作过程中突然崩溃。管理员将服务器操作系统进行了重装。 用户方需要恢复服务器中的数据库、办公文档、代码文件等。
|
27天前
|
Linux Shell
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
94 25
|
1月前
|
安全 Linux
阿里云linux服务器使用脚本通过安全组屏蔽异常海外访问ip
公网网站可能会遭受黑客攻击导致访问异常,使用此脚本可以屏蔽掉异常IP 恢复访问。也可自行设置定时任务定期检测屏蔽。
165 28
|
1月前
|
关系型数据库 MySQL Linux
在Linux环境下备份Docker中的MySQL数据并传输到其他服务器以实现数据级别的容灾
以上就是在Linux环境下备份Docker中的MySQL数据并传输到其他服务器以实现数据级别的容灾的步骤。这个过程就像是一场接力赛,数据从MySQL数据库中接力棒一样传递到备份文件,再从备份文件传递到其他服务器,最后再传递回MySQL数据库。这样,即使在灾难发生时,我们也可以快速恢复数据,保证业务的正常运行。
117 28
|
15天前
|
安全 Ubuntu Linux
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
43 0
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
|
1月前
|
JavaScript Linux Python
在Linux服务器中遇到的立即重启后的绑定错误:地址已被使用问题解决
总的来说,解决"地址已被使用"的问题需要理解Linux的网络资源管理机制,选择合适的套接字选项,以及合适的时间点进行服务重启。以上就是对“立即重启后的绑定错误:地址已被使用问题”的全面解答。希望可以帮你解决问题。
112 20
|
2月前
|
Ubuntu Linux
Linux系统管理:服务器时间与网络时间同步技巧。
以上就是在Linux服务器上设置时间同步的方式。然而,要正确运用这些知识,需要理解其背后的工作原理:服务器根据网络中的其他机器的时间进行校对,逐步地精确自己的系统时间,就像一只犹豫不决的啮齿动物,通过观察其他啮齿动物的行为,逐渐确定自己的行为逻辑,既简单,又有趣。最后希望这个过程既能给你带来乐趣,也能提高你作为系统管理员的专业素养。
136 20