标签:network help name maps www. san ash ons first
搭建服务环境: Centos 6
配置域名hosts: mail.demonC6.com
1.清理系统自带的邮件软件
# rpm -qa | grep sendmail* # rpm -e sendmail* --nodeps
2. 安装postfix软件
yum -y install postfix*
3. 配置postfix
vim /etc/postfix/main.cf
需要修改的配置如下几项,红色表示需要开启), 蓝色表示需要注释关闭:
1) 更改邮件主机名和域名
75 myhostname = mail.demonC6.com 76 #myhostname = virtual.domain.tld 77 78 # The mydomain parameter specifies the local internet domain name. 79 # The default is to use $myhostname minus the first component. 80 # $mydomain is used as a default value for many other configuration 81 # parameters. 82 # 83 mydomain = demonC6.com
2) 修改组织
94 # For the sake of consistency between sender and recipient addresses, 95 # myorigin also specifies the default domain name that is appended 96 # to recipient addresses that have no @domain part. 97 # 98 myorigin = $myhostname 99 myorigin = $mydomain
3) 修改监听的地址
113 inet_interfaces = all 114 #inet_interfaces = $myhostname 115 #inet_interfaces = $myhostname, localhost 116 #inet_interfaces = localhost
4) 修改收件人
164 mydestination = $myhostname,$mydomain 165 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 166 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, 167 # mail.$mydomain, www.$mydomain, ftp.$mydomain
5) 修改网卡所在的网段
264 mynetworks = 192.168.10.0/24, 127.0.0.0/8 265 #mynetworks = $config_directory/mynetworks 266 #mynetworks = hash:/etc/postfix/network_table
6) 修改转发的邮件域名
296 relay_domains = $mydestination
7) 修改postfix 邮件别名 (下面两项默认是开启的,不用动)
385 #alias_maps = dbm:/etc/aliases 386 alias_maps = hash:/etc/aliases 387 #alias_maps = hash:/etc/aliases, nis:mail.aliases 388 #alias_maps = netinfo:/aliases 389 390 # The alias_database parameter specifies the alias database(s) that 391 # are built with "newaliases" or "sendmail -bi". This is a separate 392 # configuration parameter, because alias_maps (see above) may specify 393 # tables that are not necessarily all under control by Postfix. 394 # 395 #alias_database = dbm:/etc/aliases 396 #alias_database = dbm:/etc/mail/aliases 397 alias_database = hash:/etc/aliases 398 #alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
4 启动postfix服务
# service postfix start
5 查看监听端口
# netstat -anptu | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2276/sshd tcp 0 40 192.168.10.129:22 192.168.10.1:56933 ESTABLISHED 6350/sshd tcp 0 0 :::22 :::* LISTEN 2276/sshd
6 自我发邮件测试
[root@demon html]# echo hello man | mail root@demonC6.com [root@demon html]# mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root Sat May 12 11:37 17/543 & 1 Message 1: From root@demonC6.com Sat May 12 11:37:49 2018 Return-Path: <root@demonC6.com> X-Original-To: root@demonC6.com Delivered-To: root@demonC6.com Date: Sat, 12 May 2018 11:37:49 +0800 To: root@demonC6.com User-Agent: Heirloom mailx 12.4 7/29/08 Content-Type: text/plain; charset=us-ascii From: root@demonC6.com (root) Status: R hello man & d & q
也可以通过telnet发邮件
[root@demon html]# telnet mail.demonC6.com 25 Trying 192.168.10.129... Connected to mail.demonC6.com. Escape character is ‘^]‘. 220 mail.demonC6.com ESMTP Postfix mail from: root@demonC6.com 250 2.1.0 Ok rcpt to: root@demonC6.com 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> Hello man, This is a test mail . 250 2.0.0 Ok: queued as EAECD44917 quit 221 2.0.0 Bye Connection closed by foreign host. You have new mail in /var/spool/mail/root [root@demon html]# mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/root": 2 messages 2 new >N 1 root@demonC6.com Sat May 12 11:42 14/513 N 2 root@demonC6.com Sat May 12 11:43 14/515 & 2 Message 2: From root@demonC6.com Sat May 12 11:43:31 2018 Return-Path: <root@demonC6.com> X-Original-To: root@demonC6.com Delivered-To: root@demonC6.com Date: Sat, 12 May 2018 11:43:10 +0800 (CST) From: root@demonC6.com To: undisclosed-recipients:; Status: R Hello man, This is a test mail & q Held 2 messages in /var/spool/mail/root
标签:network help name maps www. san ash ons first
原文地址:https://www.cnblogs.com/demonxian3/p/9028226.html