Debian10.2配置邮件服务器postfix+dovecot

解决中小局域网内邮件服务的问题,使用postfix与dovecot搭建SMTP和POP3服务器。

安装服务器组件

apt-get install –y postfix dovecot-pop3d mailutils

其中mailutils,是mail命令程序。如果不用命令行方式的话,可以不安装。

安装postfix的时候,会提示要求选择邮件服务器类型,这里选择Internet Site。

No configuration:
    Should be chosen to leave the current configuration unchanged.
Internet site:
    Mail is sent and received directly using SMTP.
Internet with smarthost:
    Mail is received directly using SMTP or by running a utility such as fetchmail. Outgoing mail is sent using a smarthost.
Satellite system:
    All mail is sent to another machine, called a 'smarthost', for delivery.
Local only:
    The only delivered mail is the mail for local users. There is no network.

进而会提示输入邮件域名,这里按需填写。(例如mail.wa.cn)

配置环境

邮件服务器IP地址=192.168.31.73,测试用户名为test(密码123)、duanjsh(密码123)。测试PC机一台,与邮件服务器三层可达。

修改/etc/hosts,把相应域名加入到hosts中。

vim /etc/hosts 
192.168.31.73   mail.wa.cn wa.cn

检查一下/etc/mailname的值是不是安装时配置的。

cat /etc/mailname
mail.wa.cn

创建一个账户进行测试:

mkdir -p /home/test
useradd test -d /home/test -g users -s /bin/bash
chown test:users /home/test -R
passwd test

postfix配置

postfix的主要配置文件是/etc/postfix/main.cf,这里按需修改。我把修改项压缩到0或1步,即修改其中的mydestination项。后面会提到这项。

dovecot配置

dovecot配置都在/etc/dovecot/下,我修改了2处:

vim /etc/dovecot/conf.d/10-auth.conf
#disable_plaintext_auth修改为
disable_plaintext_auth = no

vi /etc/dovecot/conf.d/10-ssl.conf
#ssl修改为
ssl = no

重启两个服务

service dovecot restart
service postfix restart

安装配置客户端

可以采用foxmail来作为邮件客户端。

新建账号,其他邮箱,手动设置。接收服务类型选择POP3,用户名和密码填邮件服务器内的具体用户名(test)与密码(123)。POP3和SMTP服务器地址都填写具体的服务器地址,这里假设是192.168.31.73,端口110和25均为默认。

账号管理,Email地址修改为test@mail.wa.cn。

测试

当foxmail同时配置多个用户时,在左侧可以使用A账号发邮件给B账号。

在main.cf中destination配置了mail.wa.cn,该postfix仅能接收mail.wa.cn,如果收件人是test@155.com,发送就会失败。这个destination配置项,仅监察收件人,不检查发件人。如果155.com域名不在destination中,使用test@155.com这个邮件地址作为发起方,是可以的。如果要postfix接收多个域名,就要修改destination项。

telnet测试

如果没有foxmail这种客户端,也可以使用telnet的几个命令进行测试:helo、mail from、rcpt to、data。

root@deb10:/etc/postfix# telnet localhost  25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 deb10 ESMTP Sendmail 8.15.2/8.15.2/Debian-14~deb10u1; Sun, 9 Feb 2020 18:08:20 +0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
helo abc
250 deb10 Hello localhost [127.0.0.1], pleased to meet you
mail from:root@localhost    
250 2.1.0 root@localhost... Sender ok
rcpt to:duanjsh@localhost
250 2.1.5 duanjsh@localhost... Recipient ok
data
354 Enter mail, end with "." on a line by itself
hey duan, you are so smart!
.
250 2.0.0 019A8K2I002817 Message accepted for delivery

 

  • 4
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值