获取中...

-

Just a minute...

安装

Ubuntu 18.04附带了systemd-resolve,需要禁用它,因为它绑定到53端口,与Dnsmasq端口冲突。

运行以下命令以禁用已解析的服务:

systemctl disable systemd-resolved

systemctl stop systemd-resolved

删除符号链接resolv.conf文件

ls -lh /etc/resolv.conf

53端口占用:

lsof -i:53

kill -9 pid

以下三个命令安装:

apt-get install dovecot-common dovecot-imapd dovecot-pop3d

apt-get install postfix

apt-get install dnsmasq

对应服务:

Postfix——Smtp(发送邮件)

Dovecot——POP3/IMAP(接收邮件)

Dnsmasq——nameserver(域名服务器)

配置hostname

vi /etc/hostname

更改为:

mail.ysm.com

重启后生效

配置dnsmasq

在hosts文件中增加本地IP到域名映射

命令:vi /etc/hosts

添加:192.168.75.134 mail.ysm.com

执行/etc/init.d/dnsmasq start将服务器的DNS服务器指向Dnsmasq服务器

将服务器的DNS服务器指向Dnsmasq服务器:

命令:vi /etc/resolv.conf

添加:

nameserver 127.0.0.1

nameserver 8.8.8.8

测试

配置postfix

命令:vi /etc/postfix/main.cf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
home_mailbox = Maildir/
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
compatibility_level = 2
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.ysm.com
mydomain = ysm.com
alias_maps = hash:/etc/al
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination = $myhostname, ysm.com, mail.ysm.com, localhost.ysm.com, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks, reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

启动服务:

/etc/init.d/postfix start

配置dovecot

vi /etc/dovecot/dovecot.conf

取消注释并配置

1
2
3
4
5
listen = *
protocols = pop3 imap
mail_location = maildir:/home/%u/Maildir
pop3_uidl_format = %08Xu%08Xv
disable_plaintext_auth = no

指定电子邮件客户端向Dovecot进行身份验证的方式:

vi /etc/dovecot/conf.d/10-auth.conf

auth_mechanisms = plain login

指定用于存储电子邮件的文件夹:

vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:/home/%u/Maildir

编辑Postfix SMTP身份验证配置文件:

vi /etc/dovecot/conf.d/10-master.conf

注释文件中的以下几行

1
2
3
4
5
#unix_listener auth-userdb {
#mode = 0600
#user =
#group =
#}

并确保未注释以下内容:

1
2
3
4
5
6
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}

编辑POP3配置文件,并允许一些较旧的电子邮件客户端正确连接和传输::

vi /etc/dovecot/conf.d/20-pop3.conf

pop3_uidl_format = %08Xu%08Xv

pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

为了使Dovecot服务与Postfix服务一起使用,我们需要在Postfix配置文件中添加以下几行:

vi /etc/postfix/main.cf

1
2
3
4
5
6
7
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks, reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

重启服务:

/etc/init.d/postfix restart

/etc/init.d/dovecot restart

测试服务功能:

服务器启动时自启:

update-rc.d dovecot defaults

建立邮箱账户:

重启服务:

/etc/init.d/dovecot restart

使用测试

要保证在同一个网段

邮件服务器ip:192.168.75.134

修改客户端ip: 192.168.75.1(修改方法如下)

相关文章
评论
分享
  • 网络设备配置与管理

    Linux网络设备与管理大作业 下图为某企业网络拓扑图,接入层采用二层交换机2960,汇聚和核心层使用了一台三层交换机3560 24PS,局域网边缘采用一台路由器LanRouter用于连接到外部网络的Isp Router两台路由器...

    网络设备配置与管理
  • IPTABLES防火墙配置

    iptables的基本配置方法查看是否安装防火墙which iptables whereis iptables 如上图所示,iptables已经安装,如果没有安装,使用sudo apt-get install iptables安装...

    IPTABLES防火墙配置
  • ssh服务配置

    目的掌握linux系统中ssh服务器的配置 掌握ssh安全远程登陆的方法 掌握ssh采用公钥认证登陆 条件局域网中有两台主机ip为192.168.75.134(服务器,yangshuming)和192.168.75.132(客户端ub...

    ssh服务配置
Please check the parameter of comment in config.yml of hexo-theme-Annie!