Ubuntu 18.04配置邮箱服务器(局域网)

-------------------------------------------Ubuntu 18.04配置邮箱服务器(局域网)-------------------------------------------
一、安装
  Ubuntu 18.04附带了systemd-resolve,需要禁用它,因为它绑定到53端口,与Dnsmasq端口冲突。
  运行以下命令以禁用已解析的服务:

[email protected]:$ systemctl disable systemd-resolved
[email protected]:$ systemctl stop systemd-resolved

删除符号链接resolv.conf文件

[email protected]:$ ls -lh /etc/resolv.conf

53端口占用:

[email protected]:$ lsof -i:53
[email protected]:$ kill -9 pid

安装:

[email protected]:$ apt-get install dovecot-common dovecot-imapd dovecot-pop3d
[email protected]:$ apt-get install postfix
[email protected]:$ apt-get install dnsmasq

对应服务:
  Postfix------Smtp(发送邮件)
  Dovecot------POP3/IMAP(接收邮件)
  Dnsmasq------nameserver(域名服务器)

二、配置hostname

[email protected]:$ vim /etc/hostname

更改为:
  mail.coodyz.com
  重启后生效:

[email protected]:$ reboot

三、配置dnsmasq
 在hosts文件中增加 本地IP到域名映射

[email protected]:$ vim /etc/hosts192.168.254.128 mail.coodyz.com # `192.168.254.128`更改为Ubuntu本机局域网IP

 启动服务:

[email protected]:$ /etc/init.d/dnsmasq start

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

[email protected]:$ vim /etc/resolv.conf
nameserver 127.0.0.1
nameserver 8.8.8.8

以上只是修改运行时文件,进行持久配置需编辑/etc/network/interfaces

测试:

[email protected]:$ dig A mail.coodyz.com
; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> A mail.coodyz.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47993
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;mail.coodyz.com.    IN    A

;; ANSWER SECTION:
mail.coodyz.com.    0    IN    A    192.168.254.128

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Dec 20 16:42:17 CST 2019
;; MSG SIZE rcvd: 60

四、配置postfix

[email protected]:$ vim /etc/postfix/main.cf

参考配置:

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.coodyz.com
mydomain = coodyz.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination = $myhostname, coodyz.com, mail.coodyz.com, localhost.coodyz.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

启动服务:

[email protected]:$ /etc/init.d/postfix start

五、配置dovecot
  编辑Dovecot主配置文件:

[email protected]:# vim /etc/dovecot/dovecot.conf

取消注释并配置

listen = *
protocols = pop3 imap
pop3_uidl_format = %08Xu%08Xv
mail_location = mbox:~/mail:INBOX=/var/mail/%u
disable_plaintext_auth = no

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

[email protected]:# vim /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login

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

[email protected]:# vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:/home/%u/Maildir

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

[email protected]:$ vim /etc/dovecot/conf.d/10-master.conf

注释文件中的以下几行

#unix_listener auth-userdb {
#mode = 0600
#user =
#group =
#}

并确保未注释以下内容:

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}

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

[email protected]:$ vim /etc/dovecot/conf.d/20-pop3.conf
pop3_uidl_format = %08Xu%08Xv
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

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

[email protected]:$ vim /etc/postfix/main.cf
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

重启服务:

[email protected]:$ /etc/init.d/postfix restart
[email protected]:$ /etc/init.d/dovecot restart

测试服务功能:

[email protected]:$ telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is ‘^]‘.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS
AUTH=PLAIN AUTH=LOGIN] Dovecot (Ubuntu) ready.
[email protected]:$ telnet localhost 110

服务器启动时自启

[email protected]:$ update-rc.d dovecot defaults

建立邮箱账户:

[email protected]:$ adduser ted
Enter new UNIX password: ted
Retype new UNIX password: ted
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

重启服务:

[email protected]:$ /etc/init.d/dovecot restart

六、使用测试
 注意:请确保两者在同一网段
 邮件服务器IP 192.168.254.128
 Windows XP 客户端IP 192.168.254.130

 使用outlook测试:
 工具->账户->添加

在Ubuntu端查看:

[email protected]:~$ cd ~/Maildir/new/
[email protected]:~/Maildir/new$ ls
1576825940.V801I10053cM500622.mail.coodyz.com
1576826245.V801I100544M69814.mail.coodyz.com
1576826459.V801I10054bM4159.mail.coodyz.com
1576833962.V801I10055bM300307.mail.coodyz.com
[email protected]:~/Maildir/new$ vim 1576833962.V801I10055bM300307.mail.coodyz.com

参考链接:https://www.linuxidc.com/Linux/2017-03/141392.htm

     https://computingforgeeks.com/install-and-configure-dnsmasq-on-ubuntu-18-04-lts/

     https://kyup.com/tutorials/install-dovecot/

     https://tecadmin.net/install-dovecot-on-ubuntu/

原文地址:https://www.cnblogs.com/coodyz/p/12074485.html

时间: 2024-10-01 03:12:38

Ubuntu 18.04配置邮箱服务器(局域网)的相关文章

Ubuntu 18.04安装Samba服务器及配置

Ubuntu 18.04安装Samba服务器及配置 局域网下使用samba服务在Linux系统与Windows系统直接共享文件是一项很方便的操作.以Ubuntu为例配置samba服务,Linux服务器的版本是Ubuntu 18.04.1 LTS. 在终端中执行下列指令:cat /etc/issue查看当前正在运行的 Ubuntu 的版本号. 以下是我的安装配置步骤: (1)更新当前软件. sudo apt-get upgrade  sudo apt-get update  sudo apt-ge

ubuntu 18.04 配置 rc.local

ubuntu 18.04 配置 rc.local:https://blog.csdn.net/a912952381/article/details/81205095 Ubuntu /etc/rc.local 不存在: https://blog.csdn.net/weixin_43599336/article/details/85970601 原文地址:https://www.cnblogs.com/dhcn/p/10660465.html

Ubuntu 18.04配置OpenCV 4.2.0

目录 Step 1: 安装OpenCV的依赖包 Step 2: 下载OpenCV 4.2.0和OpenCV Contrib 4.2.0 Step 3: 使用cmake构建库 Step 4: 使用make构建库 Step 5: 修改opencv4.pc文件 Step 6: 在.bashrc文件中添加PKG_CONFIG_PATH Step 7: 使用C++代码进行验证 本文主要介绍在Ubuntu 18.04中从源码安装配置OpenCV,并使用一个简单的例子验证是否安装成功: 具体安装配置步骤,参考

Ubuntu 18.04配置MongoDB密码登录

系统: Ubuntu 18.04MongoDB: 4.2,3 安装MongoDB server 和client(测试用) # 添加MongoDB GPG密钥 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B # 创建MongoDB存储库 echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-or

ubuntu 18.04 配置notebook远程连接的坑

jupyter-notebook的安装不在此说明 在网上搜了很多方案都不行,好不容易从坑里爬出来 以下为远程连接配置方法 1.生成配置文件 1 jupyter notebook --generate-config 2.生成连接密钥 这里有两种方法 先说第一种:使用password指令生成密钥,生成的密钥在一个文件里 jupyter notebook password 第二种方法:在python环境中生成密钥 ipython from notebook.auth import passwd pas

Ubuntu 18.04 配置 Redis 单机主从

安装 sudo apt update sudo apt install redis 测试(以下为正常) [email protected]:~$ redis-cli 127.0.0.1:6379> ping PONG 使用 systemctl 管理 redis # 查看状态 $ systemctl status redis # 启动redis $ systemctl start redis #重启redis $ systemctl restart redis # 停止redis $ system

Ubuntu 18.04 LTS安装Samba服务及配置

局域网下使用samba服务在Linux系统与Windows系统直接共享文件是一项很方便的操作.以Ubuntu为例配置samba服务,Linux服务器的版本是Ubuntu 18.04.1 LTS. 在终端中执行下列指令:cat /etc/issue查看当前正在运行的 Ubuntu 的版本号. 以下是我的安装配置步骤: (1)更新当前软件. sudo apt-get upgrade sudo apt-get update sudo apt-get dist-upgrade (2)安装samba服务器

Ubuntu 18.04 实验环境配置

Ubuntu 18.04 实验环境配置 系统:Ubuntu 18.04 64bit 显卡:Nvidia GeForce 1080Ti 下载 CUDA.cuDNN.NVIDIA间存在某种关系,建议先确定要安装的CUDA版本. 注意:后续要安装的一些包不支持CUDA9.1. CUDA下载地址:https://developer.nvidia.com/cuda-toolkit-archive cuDNN下载地址:https://developer.nvidia.com/rdp/cudnn-archiv

Win10+WSL2+Ubuntu 18.04(WSL下)+VS Code(Win10下)+TexLive 2019(Ubuntu下)安装和配置

本人手头电脑是Win10 Home版全新安装的系统,由于不想在新系统盘里面安装TexLive导致固态硬盘不断扩大,所以,考虑安装Ubuntu做为WSL,然后把TexLive安装在Ubuntu,并通过VS Code调用Ubuntu命令来写Latex的方法来写一些论文.在此,提供一个思路给大家借鉴. Windows 10安装WSL2和Ubuntu 18.04 这个过程其实直接参照微软的标准过程就可以了,大致步骤总结如下: 去控制面板开启Virtual Machine Platform和Windows