手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

配置Postfix服务程序

时间:2024-10-13 23:15:23

1、安装Postfix服务程序,当然这一步在红帽RHEL7系统中是多余的,刘遄老师把步骤写下来的目的是为了让同学们读完这本《Linux就该这么学》后不仅能够掌握红帽RHEL系统,还能立即上手fedora、centos等等主流的Linux系统,当那些系统没有Postfix服务程序的时候也不用慌~对了,最后记得把iptables防火墙给禁用掉,否则会导致外部用户访问不了咱们的电子邮件系统。[root@linuxprobe ~]# yum install postfixLoaded plugins: langpacks, product-id, subscription-managerrhel7 | 4.1 kB 00:00(1/2): rhel7/group_gz | 134 kB 00:00(2/2): rhel7/primary_db | 3.4 MB 00:00Package 2:postfix-2.10.1-6.el7.x86_64 already installed and latest version Nothing to do[root@linuxprobe ~]# systemctl disable iptables

2、配置Postfix服务程序,对于初次看到Postfix服务程序主配置文件(/etc/post酆璁冻嘌fix/main.艘早祓胂cf)的同学一定会被吓到吧,竟然足足有679行左右呢,但其实不必担心,这里面绝大多数的内容依然是注释信息,而且刘遄老师一直在强调Linux系统正确的学习方法,负责任的好老师不应只是做书本的搬运工,更应该做一名优质内容的提炼者。Postfix服务程序总共需要修改五处,首先是在约76行左右定义有一个名称为myhostname的变量,它用来保存服务器的主机名称,读者请记住这个变量的名称,下边参数需要调用它:[root@linuxprobe ~] # vim /etc/postfix/main.cf# INTERNET HOST AND DOMAIN NAMES## The myhostname parameter specifies the internet hostname of this# mail system. The default is to use the fully-qualified domain name# from gethostname(). $myhostname is used as a default value for many # other configuration parameters.##myhostname = host.domain.tldmyhostname = mail.linuxprobe.com第二处是约83行左右定义有一个名称为mydomain的变量,用来保存邮件域的名称,同学们也要记住这个变量名称,下面来调用它:# The mydomain parameter specifies the local internet domain name.# The default is to use $myhostname minus the first component.# $mydomain is used as a default value for many other configuration# parameters. #mydomain = linuxprobe.com第三处是约99行左右调用前面的mydomain变量,用来定义寄出邮件的域,调用变量的好处是避免重复写入信息以及便于今后统一进行修改:# SENDING MAIL## The myorigin parameter specifies the domain that locally-posted# mail appears to come from. The default is to append $myhostname,# which is fine for small sites. If you run a domain with multiple# machines, you should (1) change this to $mydomain and (2) set up# a domain-wide alias database that aliases each user to# [email protected].## For the sake of consistency between sender and recipient addresses,# myorigin also specifies the default domain name that is appended# to recipient addresses that have no @domain part.# #myorigin = $myhostnamemyorigin = $mydomain第四处是约116行左右定义的网卡监听地址,您可以指定要由服务器的那些IP地址对外提供电子邮件服务,也可以干脆写成all,代表所有网卡都能向客户提供电子邮件服务:# The inet_interfaces parameter specifies the network interface# addresses that this mail system receives mail on. By default,# the software claims all active interfaces on the machine. The# parameter also controls delivery of mail to user@[ip.address].## See also the proxy_interfaces parameter, for network addresses that# are forwarded to us via a proxy or network address translator.## Note: you need to stop/start Postfix when this parameter changes.# #inet_interfaces = all#inet_interfaces = $myhostname#inet_interfaces = $myhostname, localhostinet_interfaces = all最后第五处是约164行左右定义的可接收邮件的主机名或域名列表,此处可以直接调用前面两个定义好的myhostname,mydomain变量即可(当然不想调用变量,直接写名称信息的话也可以):# The mydestination parameter specifies the list of domains that this# machine considers itself the final destination for.## These domains are routed to the delivery agent specified with the# local_transport parameter setting. By default, that is the UNIX# compatible delivery agent that lookups all recipients in /etc/passwd# and /etc/aliases or their equivalent.## The default is $myhostname + localhost.$mydomain. On a mail domain# gateway, you should also include $mydomain.## Do not specify the names of virtual domains - those domains are# specified elsewhere (see VIRTUAL_README).## Do not specify the names of domains that this machine is backup MX # host for. Specify those names via the relay_domains settings for# the SMTP server, or use permit_mx_backup if you are lazy (see# STANDARD_CONFIGURATION_README).## The local machine is always the final destination for mail addressed# to user@[the.net.work.address] of an interface that the mail system# receives mail on (see the inet_interfaces parameter).## Specify a list of host or domain names, /file/name or type:table# patterns, separated by commas and/or whitespace. A /file/name# pattern is replaced by its contents; a type:table is matched when# a name matches a lookup key (the right-hand side is ignored).# Continue long lines by starting the next line with whitespace.## See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".# mydestination = $myhostname, localhost.$mydomain, localhost#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomainmydestination = $myhostname, $mydomain

3、创建电子邮件系统的登陆帐号,Postfix与Vsftpd服务程序一样都可以调用本地系统帐号和密码,因此在本地进行常规帐号创建即可,最后再把配置妥当的postfix服务重启,加入到开机启动项中就大功告成了!~[root@linuxprobe ~] # useradd boss[root@linuxprobe~] # echo "linuxprobe" | passwd --stdin bossChanging password for user boss. passwd: all authentication tokens updated successfully.[root@linuxprobe~] # systemctl restart postfix[root@linuxprobe~] # systemctl enable postfixln -s '/usr/lib/systemd/system/postfix.service' '/etc/systemd/system/multi-user.target.wants/postfix.service'

© 手抄报圈