linux环境下启用postfix服务进行域名邮件收发

本文档详细介绍了如何在Linux系统中安装并配置Postfix服务,以实现使用特定域名发送和接收电子邮件。步骤包括安装Postfix、编辑主配置文件设置主机名、域名、邮件来源等参数,然后重启服务。最后通过示例展示了成功发送和接收邮件的过程。
摘要由CSDN通过智能技术生成

linux环境下启用postfix服务进行域名邮件收发

安装服务

[root@kittod ~]# dnf install postfix mailx -y

1.编辑postfix服务的主配置文件

[root@kittod ~]# vim /etc/postfix/main.cf
87 # INTERNET HOST AND DOMAIN NAMES
88 #
89 # The myhostname parameter specifies the internet hostname of this
90 # mail system. The default is to use the fully-qualified domain name
91 # from gethostname(). $myhostname is used as a default value for many
92 # other configuration parameters.
93 #
94 myhostname = mail.baidu.com
95 #myhostname = virtual.domain.tld
96
97 # The mydomain parameter specifies the local internet domain name.
98 # The default is to use $myhostname minus the first component.
99 # $mydomain is used as a default value for many other configuration
100 # parameters.
101 #
102 mydomain = baidu.com
104 # SENDING MAIL
105 #
106 # The myorigin parameter specifies the domain that locally-posted
107 # mail appears to come from. The default is to append $myhostname,
108 # which is fine for small sites. If you run a domain with multiple
109 # machines, you should (1) change this to $mydomain and (2) set up
110 # a domain-wide alias database that aliases each user to
111 # user@that.users.mailhost.
112 #
113 # For the sake of consistency between sender and recipient addresses,
114 # myorigin also specifies the default domain name that is appended
115 # to recipient addresses that have no @domain part.
116 #
117 #myorigin = $myhostname
118 myorigin = $mydomain
120 # RECEIVING MAIL
121
122 # The inet_interfaces parameter specifies the network interface
123 # addresses that this mail system receives mail on. By default,
124 # the software claims all active interfaces on the machine. The
125 # parameter also controls delivery of mail to user@[ip.address].
126 #
127 # See also the proxy_interfaces parameter, for network addresses that
128 # are forwarded to us via a proxy or network address translator.
129 #
130 # Note: you need to stop/start Postfix when this parameter changes.
131 #
132 inet_interfaces = all
152 # The mydestination parameter specifies the list of domains that this
153 # machine considers itself the final destination for.
154 #
155 # These domains are routed to the delivery agent specified with the
156 # local_transport parameter setting. By default, that is the UNIX
157 # compatible delivery agent that lookups all recipients in /etc/passwd
158 # and /etc/aliases or their equivalent.
183 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
272 # Alternatively, you can specify the mynetworks list by hand, in
273 # which case Postfix ignores the mynetworks_style setting.
274 #
275 # Specify an explicit list of network/netmask patterns, where the
276 # mask specifies the number of bits in the network part of a host
277 # address.
278 #
279 # You can also specify the absolute pathname of a pattern file instead
280 # of listing the patterns here. Specify type:table for table-based lookups
281 # (the value on the table right-hand side is not used).
282 #
283 mynetworks = 192.168.226.0/24, 127.0.0.0/8
315 relay_domains = $mydestination

2.重新启动服务

[root@kittod ~]# systemctl restart postfix

3.发邮件给redhat用户

[root@kittod ~]# mail redhat@haha.com
Subject: test02
这是测试内容
EOT

4.切换到redhat用户进行查看

[root@kittod ~]# su - redhat
Last login: Mon Oct 25 15:46:13 CST 2021 on pts/0
[redhat@kittod ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/redhat": 2 messages 1 unread
1 root Mon Oct 25 15:46 21/597 "test01"
>U 2 root Mon Oct 25 17:53 20/615 "test02"
& 2
Message 2:
From root@haha.com Mon Oct 25 17:53:03 2021
Return-Path: <root@haha.com>
X-Original-To: redhat@haha.com
Delivered-To: redhat@haha.com
Date: Mon, 25 Oct 2021 17:53:03 +0800
To: redhat@haha.com
Subject: test02
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=utf-8
From: root <root@haha.com>
X-UID: 6
Status: RO
这是测试内容
&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值