基本流程及软件版本
最近在为公司搭建私有服务器环境,调研了一些开源或付费软件,最后选择自己配置软件环境,以下为配置过程及测试。
安装postfix
1、安装命令
yum install postfix
2、配置
#取消注释,设置hostname myhostname = mail.domain.com #取消注释,设置域名 mydomain = doamin.com #99行: 取消注释 myorigin = $mydomain #116行: 默认是localhost,我们需要修改成all inet_interfaces = all #119行: 推荐ipv4,如果支持ipv6,则可以为all inet_protocols = ipv4 #164行: 添加 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #取消注释,指定内网和本地的IP地址范围 mynetworks = 127.0.0.0/8 #也可以使用0.0.0.0/0使用所有ip及端口号 #取消注释,邮件保存目录 home_mailbox = Maildir/ #添加 smtpd_banner = $myhostname ESMTP #添加到最后 #规定邮件最大尺寸为10M message_size_limit = #规定收件箱最大容量为1G mailbox_size_limit = #SMTP认证 smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
启动postfix服务
/bin/systemctl start postfix.service
安装配置dovect
1、安装命令
yum install dovecot
2、配置
编辑文件dovecot.conf
#26行: 如果不使用IPv6,请修改为* listen = * #在主配置文件中的第48行,设置允许登录的网段地址,也就是说我们可以在这里限制只有来自于某个网段的用户才能使用电子邮件系统。如果想允许所有人都能使用,则不用修改本参数 login_trusted_networks = 192.168.10.0/24更改内容
编辑文件10-auth.conf
# 9行: 取消注释并修改 disable_plaintext_auth = no # 97行: 添加 auth_mechanisms = plain login
编辑文件10-mail.conf
# 30行: 取消注释并添加 mail_location = maildir:~/Maildir
编辑文件10-master.conf
# 88-90行: 取消注释并添加 # Postfix smtp验证 unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix }
注意:如果我们没有使用ssl的话需要进行下面的操作。使用了则不需要。
编辑文件10-ssl.conf
vim /etc/dovecot/conf.d/10-ssl.conf
更改内容
# 8行: 将ssl的值修改为 ssl = no
启动dovecot服务
/bin/systemctl start dovecot.service
收发邮件测试
创建用户
内部相互发送及接口邮件
1、 发送邮件给 test@domain.com
[root@mail ~]# telnet mail.domain.com 25 Trying 47.106.14.53... Connected to mail.domain.com. Escape character is '^]'. 220 mail.domain.com ESMTP mail from: 250 2.1.0 Ok rcpt to: 250 2.1.5 Ok data 354 End data with
.
subject:title data 22.52 current data 22.52 . 250 2.0.0 Ok: queued as 72B6D2E4A3E quit 221 2.0.0 Bye Connection closed by foreign host.
2、接收邮件
[root@mail ~]# telnet mail.domain.com 110 Trying 47.106.14.53... Connected to mail.domain.com. Escape character is '^]'. +OK Dovecot ready. user test #用户名 +OK pass pps #密码 +OK Logged in. list #查看邮件表列 +OK 3 messages: 1 318 2 316 3 320 . retr 3 #查看第三封邮件 +OK 320 octets Return-Path:
X-Original-To: Delivered-To: Received: from mail.domain.com (mail.domain.com [47.106.14.53]) by mail.domain.com (Postfix) with SMTP id 72B6D2E4A3E for
; Sat, 2 Mar 2019 22:53:29 +0800 (CST) subject:title data 22.52 current data 22.52 . quit +OK Logging out. Connection closed by foreign host.
二、测试向外发送邮件
[root@mail ~]# telnet mail.doamin.com 25 Trying 47.106.14.53... Connected to mail.doamin.com. Escape character is '^]'. 220 mail.doamin.com ESMTP mail from: 250 2.1.0 Ok rcpt to:@.com 250 2.1.5 Ok data 354 End data with
.
subject : title data 22.58 current data 22.58 . 250 2.0.0 Ok: queued as 9BFEB2E4A3E quit 221 2.0.0 Bye Connection closed by foreign host.

三、测试接收外部邮件
<发送邮件图片>
[root@mail ~]# telnet mail.doamin.com 110 Trying 47.106.14.53... Connected to mail.doamin.com. Escape character is '^]'. +OK Dovecot ready. user admin +OK pass pps +OK Logged in. list #查看邮件列表 +OK 5 messages: 1 308 2 310 3 319 4 2193 5 2222 . retr 5 #查看第五封邮件内容 +OK 2222 octets Return-Path: <@.com> X-Original-To: Delivered-To: Received: from .com (smtpbg444..com [183.3.255.70]) by mail.domain.com (Postfix) with ESMTP id 1D25F2E4A3E for
; Sat, 2 Mar 2019 23:01:13 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=.com; s=s; t=; bh=8VMnXLV8s/vR/yNskrwsUijPh8yUrQxvgShswDZnk+Q=; h=From:To:Subject:Mime-Version:Content-Type:Content-Transfer-Encoding:Date:Message-ID; b=Gb/eqFRLNBmDbjWKQNvIAC5/nglqam4Mrun8CCmpM9fe7JVZRyEFr7I+pGHx65aQ8 EKU5m7KWbEq6qaEwQlz9pOVIYT2Qi1LVW5a55a19aJV4hOeY8mBXfjdUuj9N3QmIsS q67oBpx6PXLuuvj4MLhdWEMNOEaDVViZItkoSr4A= X--FEAT: +aXnTtpxapCdoUeeHGlPBM+1f42sdnOhpWnBk/Qur6mW/Nl3RjF2j7II3rEsa ejy1CbWCcffVMaANUOdjP8Q9hotmWSzJEZorY5xPrWDeBgP956KqLkrYafMNClOrEV4Gm0y GN6HQ4xA5OgxGNDjeUOcRM/CcXmbcsQ0CUnP8lk1IRxdODUqBzKUGBWpctm+8enCbQsg/FR Q6M6hi4npvvQYXeFHqXnut0qLxgFqBkWeKqv9pyO/5BE8oR66pd3LEcp09rDxTPA= X--SSF: 00000000000000F000000000000000Z X-HAS-ATTACH: no X--BUSINESS-ORIGIN: 2 X-Originating-IP: 123.98.213.202 X--STYLE: X--mid: webmail71tt From: "=?gb18030?B?t+PStg==?=" <@.com> To: "=?gb18030?B?YWRtaW4=?="
Subject: title 23.00 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_5C7A9AB7_0AD78F50_0D9478DF" Content-Transfer-Encoding: 8Bit Date: Sat, 2 Mar 2019 23:01:11 +0800 X-Priority: 3 Message-ID:
X--MIME: TCMime 1.0 by Tencent X-Mailer: Mail 2.x X--Mailer: Mail 2.x X--SENDSIZE: 520 Received: from .com (unknown [127.0.0.1]) by smtp..com (ESMTP) with SMTP id ; Sat, 02 Mar 2019 23:01:12 +0800 (CST) Feedback-ID: webmail:.com:bgweb:bgweb18 This is a multi-part message in MIME format. ------=_NextPart_5C7A9AB7_0AD78F50_0D9478DF Content-Type: text/plain; charset="gb18030" Content-Transfer-Encoding: base64 Y3VycmVudCAyMy4wMA== ------=_NextPart_5C7A9AB7_0AD78F50_0D9478DF Content-Type: text/html; charset="gb18030" Content-Transfer-Encoding: base64 PGRpdj5jdXJyZW50IDIzLjAwPC9kaXY+ ------=_NextPart_5C7A9AB7_0AD78F50_0D9478DF-- .
发送邮件图片>
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/222285.html原文链接:https://javaforall.net
