如何在Ubuntu或者Debian设置邮件服务器

如何在Ubuntu或者Debian设置邮件服务器,第1张

1先决条件
每个域必须有一个DNS服务器。建议不要使用Live域用于测试目的。在本教程中,将在实验室环境中使用测试域exampletst。在这个假设域名的DNS服务器应该在至少以下记录。
exampletst的forward zone配置:
IN MX 10 mailexampletst
mailexampletst IN A 192168101
exampletst的Reverse zone配置:
192168101 IN PTR mailexampletst
在配置邮件服务器的过程中,这些记录可以根据系统的要求进行修改。
2设置主机名
首先,必须在/etc/hostname和/etc/hosts文件中指定邮件服务器的主机名。前者应仅包含主机名。
root@mail:~# vim /etc/hostname
mail
root@mail:~# vim /etc/hosts
## IP Fully Qualified Domain Name Hostname ##
192168101 mailexampletst mail
增加用户
每一个Linux用户,在默认情况下,系统会为其自动创建一个邮箱。这些用户和邮箱将被用作电子邮件帐户和它们各自的邮箱。创建一个用户是很容易的。
root@mail:~# adduser fourbyte
安装和配置SMTP
服务: postfix
配置文件路径 /etc/postfix/
执行脚本 /etc/initd/postfix
日志文件 /var/log/maillog
端口 TCP/25
SMTP:安装postfix
postfix是广泛使用的SMTP服务器之一,因为它是稳定的、轻量级的、可扩展的、高度可定制的。安装postfix可以使用apt-get的完成。
root@mail:~# apt-get install postfix
在安装过程中,需要指定电子邮件服务器和域名的类型。
由于此邮件服务器就会直接向目的地发送电子邮件,我们选择Internet Site。
邮件服务器的域名也需要配置,这可以从确保该邮件服务器发送的所有邮件都有@ exampletst作为发件人域。
postfix的配置文件存储在/etc/postfix目录。下面的配置文件是非常重要的。他们中的一些可能不存在,因此需要手动创建。
transport:主要用于定义邮件如何被路由到特定的目标域。绕过DNS查询可以是一个很好的例子。在这种情况下,人们可以发送到域XYZcom的电子邮件直接通过IP地址XYYX不考虑任何DNS查询的结果。
access:可用于安全目的,如阻止发件人/收件人和他们的域名。
aliases:用于定义用户别名。例如,发送到userA的邮件可以由userB和userC接收。
maincf:是postfix的配置文件。
SMTP:准备配置文件
差不多可以准备配置文件了。transport与aliases配置文件没有默认提供,需要手动创建。
root@mail:~# cd /etc/postfix
root@mail:/etc/postfix# touch transport aliases
maincf
首先需要备份maincf然后再进行修改。根据下面的配置添加或修改配置文件。有关参数的更多详细信息,请参阅官方README和配置手册。
root@mail:/etc/postfix# vim maincf
## the name of the server ##
myhostname = mailexampletst
## alias definitions ##
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
## transport definition ##
transport_maps = hash:/etc/postfix/transport
## myorigin defines the domain name for emails originated from this server In this case, all outgoing mail should have '@exampletst' as sender domain ##
myorigin = exampletst
## mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine ##
mydestination = mailexampletst, localhostexampletst, localhost, hash:/etc/postfix/transport
## the smarthost address Not used in this tutorial and will be covered in the future##
relayhost =
## the trusted sender networks postfix will not forward mails originated from other subnets ##
mynetworks = 127000/8 [::ffff:127000]/104 [::1]/128 192168100/24
## mailbox size in bytes 0 denotes no limit ##
mailbox_size_limit = 0
## postfix will listen on all available interfaces ie eth0, eth1, eth2 and so on ##
inet_interfaces = all
transport
邮件域exampletst被定义为在本地传递不需要任何DNS查询。
root@mail:/etc/postfix# vim transport
exampletst local:
exampletst local:
root@mail:/etc/postfix# postmap transport
aliases
假设所有发送到userA的所有电子邮件可以由userB接收,别名文件需要按如下所述进行修改

有exaple邮箱,examplecom的邮箱是苹果提示输入邮箱的默认格式,不是邮件服务器
可以在提示输入example@mecom的时候输入自己的邮箱,比如QQ的,然后注册,登陆QQ邮箱验证激活


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/13448129.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-08
下一篇 2023-08-08

发表评论

登录后才能评论

评论列表(0条)

保存